On Wed, May 24, 2017 at 02:47:08PM -0400, Jason Merrill wrote: > On Wed, May 24, 2017 at 11:08 AM, Jakub Jelinek <ja...@redhat.com> wrote: > > On Wed, May 24, 2017 at 04:16:30PM +0200, Andreas Schwab wrote: > >> FAIL: g++.dg/ext/integer-pack2.C -std=gnu++11 (test for excess errors) > >> Excess errors: > >> /daten/aranym/gcc/gcc-20170524/gcc/testsuite/g++.dg/ext/integer-pack2.C:10:48: > >> error: overflow in constant expression [-fpermissive] > >> /daten/aranym/gcc/gcc-20170524/gcc/testsuite/g++.dg/ext/integer-pack2.C:10:48: > >> error: overflow in constant expression [-fpermissive] > > > > To be precise, it fails only on 32-bit targets. > > > If we at that point want some wider integer that when cast to int > > is 0 (or small enough positive number?), shall we use something like > > this, or say 1LL << (sizeof (int) * __CHAR_BIT__), or 2LL * INT_MIN, > > something else? > > This is fine. > > > Do we need to include <limits.h>? Or can we replace > > INT_MAX with __INT_MAX__? > > __INT_MAX__ sounds good. > > > Not sure about that -2147483650 for 16-bit int targets (perhaps the test can > > be guarded with int32 effective target). > > Yes, restricting the test to int32 seems like the easiest fix.
Ok, I've committed this (also add something to avoid failing on hypothetical 64-bit int 64-bit long long target). Tested for both -m32 and -m64 on x86_64-linux. 2017-05-24 Jakub Jelinek <ja...@redhat.com> * g++.dg/ext/integer-pack2.C: Require int32 effective target. Don't include limits.h. (w): Conditionalize on long long wider than int. Use 1LL << (__SIZEOF_INT__ * __CHAR_BIT__) instead of -9223372036854775808. (x): Use __INT_MAX__ instead of INT_MAX. --- gcc/testsuite/g++.dg/ext/integer-pack2.C.jj 2017-05-24 11:59:01.000000000 +0200 +++ gcc/testsuite/g++.dg/ext/integer-pack2.C 2017-05-24 21:07:02.000000000 +0200 @@ -1,12 +1,12 @@ -// { dg-do compile { target c++11 } } +// { dg-do compile { target { c++11 && int32 } } } // { dg-options -w } -#include <limits.h> - template<typename T, T...> struct integer_sequence { }; template<typename T, T num> using make_integer_sequence = integer_sequence<T, __integer_pack(num)...>; // { dg-error "argument" } -make_integer_sequence<int, -9223372036854775808> w; -make_integer_sequence<int, INT_MAX> x; // { dg-message "required" } +#if __SIZEOF_LONG_LONG__ > __SIZEOF_INT__ +make_integer_sequence<int, 1LL << (__SIZEOF_INT__ * __CHAR_BIT__)> w; +#endif +make_integer_sequence<int, __INT_MAX__> x; // { dg-message "required" } make_integer_sequence<int, -2147483650> y; // { dg-message "required" } Jakub