https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61469

--- Comment #14 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Thomas Mercier from comment #13)
> Was this feature meant to be protected by -std=c23? It doesn't appear to be
> in GCC 13:
> 
> /tmp$ cat test.c
> enum node_stat_item : unsigned {
>       NR_LRU_BASE = -1,
>       NR_INACTIVE_ANON = NR_LRU_BASE, /* must match order of LRU_[IN]ACTIVE */
>       NR_ACTIVE_ANON,         /*  "     "     "   "       "         */
>       NR_INACTIVE_FILE,
> };
> 
> int main()
> {}
> /tmp$ gcc --version
> gcc (Debian 13.2.0-10) 13.2.0
> Copyright (C) 2023 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> 
> /tmp$ gcc -std=c11 test.c
> test.c:2:23: error: enumerator value outside the range of underlying type
>     2 |         NR_LRU_BASE = -1,
>       |                       ^
> test.c:4:9: error: overflow in enumeration values
>     4 |         NR_ACTIVE_ANON,         /*  "     "     "   "       "       
> */
>       |

Note that is the correct error even for C23. clang also errors out the similar
way:
```
<source>:5:2: error: enumerator value 4294967296 is not representable in the
underlying type 'unsigned int'
    5 |         NR_ACTIVE_ANON,         /*  "     "     "   "       "        
*/
      |         ^
```

Reply via email to