2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / ubsan / pr81111.C
blob6d54a2fdf91f8bea8435ed5747bcef49b66ea423
1 // PR sanitizer/81111
2 // { dg-do compile }
3 // { dg-options "-fsanitize=shift" }
5 template <typename V>
6 struct N
8   static const V m = (((V)(-1) < 0)
9                       ? (V)1 << (sizeof(V) * __CHAR_BIT__ - ((V)(-1) < 0))
10                       : (V) 0);
13 template<typename V>
14 const V N<V>::m;
16 template <typename V>
17 struct O
19   static const V m = (V)1 << sizeof(V) * __CHAR_BIT__;
22 template<typename V>
23 const V O<V>::m;
25 void
26 foo ()
28   N<long long>::m;
29   N<unsigned long long>::m;
30 #ifdef __SIZEOF_INT128__
31   N<__int128>::m;
32   N<unsigned __int128>::m;
33 #endif
36 void
37 bar ()
39   O<long long>::m;
40   O<unsigned long long>::m;
41 #ifdef __SIZEOF_INT128__
42   O<__int128>::m;
43   O<unsigned __int128>::m;
44 #endif