On Tue, Oct 18, 2022 at 02:08:40PM +0000, Joseph Myers wrote: > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/c2x-enum-1.c > @@ -0,0 +1,104 @@ > +/* Test C2x enumerations with values not representable in int. */ > +/* { dg-do compile } */ > +/* { dg-options "-std=c2x -pedantic-errors" } */ > + > +/* Check a type while defining an enum (via a diagnostic for incompatible > + pointer types if the wrong type was chosen). */ > +#define TYPE_CHECK(cst, type) > \ > + cst ## _type_check = sizeof (1 ? (type *) 0 : (typeof (cst) *) 0) > + ...
> +/* Likewise, for overflow from long to long long. */ > +#if __LONG_LONG_MAX__ > __LONG_MAX__ > +enum e5 { e5a = __LONG_MAX__, > + e5b, e5c, e5d = ((typeof (e5b)) -1) < 0, > + e5e = (unsigned long) -1, > + e5f, e5g = ((typeof (e5e)) -1) > 0, > + TYPE_CHECK (e5a, long), TYPE_CHECK (e5e, unsigned long) }; This fails on x86_64-linux with -m32 and I assume most other 32-bit targets, it works with TYPE_CHECK (e5a, int), TYPE_CHECK (e5e, unsigned long) }; Haven't checked in detail, but if int and long have the same bitsize, doesn't __LONG_MAX__ fit into int and so this new handling of large enumerators doesn't apply? Can we just change that unconditionally, or shall it be conditional on #if __LONG_MAX__ > __INT_MAX__ (then use long, otherwise int)? Jakub