view gcc/testsuite/g++.dg/ubsan/pr81111.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
line wrap: on
line source

// PR sanitizer/81111
// { dg-do compile }
// { dg-options "-fsanitize=shift" }

template <typename V>
struct N
{
  static const V m = (((V)(-1) < 0)
		      ? (V)1 << (sizeof(V) * __CHAR_BIT__ - ((V)(-1) < 0))
		      : (V) 0);
};

template<typename V>
const V N<V>::m;

template <typename V>
struct O
{
  static const V m = (V)1 << sizeof(V) * __CHAR_BIT__;
};

template<typename V>
const V O<V>::m;

void
foo ()
{
  N<long long>::m;
  N<unsigned long long>::m;
#ifdef __SIZEOF_INT128__
  N<__int128>::m;
  N<unsigned __int128>::m;
#endif
}

void
bar ()
{
  O<long long>::m;
  O<unsigned long long>::m;
#ifdef __SIZEOF_INT128__
  O<__int128>::m;
  O<unsigned __int128>::m;
#endif
}