2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / torture / pr51436.C
blobb01a33ca2431c39cba2158186f1a4ddcdc4ca91b
1 /* { dg-do compile } */
2 /* { dg-additional-options "-Wno-return-type" } */
4 typedef __SIZE_TYPE__ size_t;
5 extern "C" void *memcpy (void *, __const void *, size_t);
6 template < class Dest, class Source > struct BitCastHelper {
7     static Dest cast (const Source & source) __attribute__ ((always_inline)) {
8         Dest dest;
9         memcpy (0, &source, sizeof dest);
10     }
12 template < class Dest, class Source > Dest BitCast (Source)
14   BitCastHelper < Dest, Source >::cast (0);
17 class MaybeObject
20 class Object:MaybeObject
22 public:
23     static Object *cast (Object *) {
24     }
26 class HeapObject:public Object
29 class String:public HeapObject
32 class ExternalString:public String
35 class ExternalTwoByteString:public ExternalString
39 template < typename T > class Handle
41 public:
42     Handle () {
43     }
44     T *operator* () const;
45     template < class S > static Handle < T > cast (Handle < S > that) {
46         T::cast (*that);
47     }
48     T **location_;
51 template < typename T > T * Handle < T >::operator* () const
53   *BitCast < T ** >(location_);
56 void
57 TestCharacterStream ()
59   Handle < String > uc16_string;
60   Handle < ExternalTwoByteString >::cast (uc16_string);