1 // PR c++/81169 - -Wclass-memaccess illegitimate warning related to volatile
3 // { dg-options "-Wclass-memaccess" }
7 void cast_const (const S *p)
9 __builtin_memset (const_cast<S*>(p), 0, sizeof *p);
12 void cast_volatile (volatile S *p)
14 __builtin_memset (const_cast<S*>(p), 0, sizeof *p);
17 void cast_const_volatile (const volatile S *p)
19 __builtin_memset (const_cast<S*>(p), 0, sizeof *p);
22 void c_cast_const_volatile (const volatile S *p)
24 __builtin_memset ((S*)p, 0, sizeof *p);
27 // A C cast to void* suppresses the warning because it casts away
28 // the qualifiers from the otherwise trivial pointed-to type..
29 void c_void_cast_const_volatile (const volatile S *p)
31 __builtin_memset ((void*)p, 0, sizeof *p);
34 // Also verify that casting to char* suppresses the warning for
40 NonTrivial (const NonTrivial&);
41 NonTrivial& operator= (const NonTrivial&);
45 void cast_void (NonTrivial *p)
47 __builtin_memset (reinterpret_cast<char*>(p), 0, sizeof *p);
50 // A C cast to a character (or any trivial) type suppresses the warning.
51 void c_cast_uchar (NonTrivial *p)
53 __builtin_memset ((unsigned char*)p, 0, sizeof *p);
56 void c_cast_void (NonTrivial *p)
58 __builtin_memset ((void*)p, 0, sizeof *p); // { dg-bogus "\\\[-Wclass-memaccess]" }