1 // PR sanitizer/81111 2 // { dg-do compile } 3 // { dg-options "-fsanitize=shift" } 4 5 template <typename V> 6 struct N 7 { 8 static const V m = (((V)(-1) < 0) 9 ? (V)1 << (sizeof(V) * __CHAR_BIT__ - ((V)(-1) < 0)) 10 : (V) 0); 11 }; 12 13 template<typename V> 14 const V N<V>::m; 15 16 template <typename V> 17 struct O 18 { 19 static const V m = (V)1 << sizeof(V) * __CHAR_BIT__; 20 }; 21 22 template<typename V> 23 const V O<V>::m; 24 25 void foo()26foo () 27 { 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 34 } 35 36 void bar()37bar () 38 { 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 45 } 46