This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/81845] const union's field doesn't interpret as const in switch/case
- From: "alenuke at yandex dot ru" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 16 Aug 2017 10:59:42 +0000
- Subject: [Bug c/81845] const union's field doesn't interpret as const in switch/case
- Auto-submitted: auto-generated
- References: <bug-81845-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81845
--- Comment #4 from Aleksandr Slobodeniuk <alenuke at yandex dot ru> ---
> Fields of const-qualified structs and unions, that were initialized with
> const literals ARE *constant expressions*, isn't it?
Maybe that's the answer:
C11 standard.
6.6 Constant expressions.
> 6 Aninteger constant expression117) shall have integer type and shall only
> have operands that are integer constants, enumeration constants, character
> constants, sizeof expressions whose results are integer constants,
> _Alignof expressions, and floating constants that are the immediate
> operands of casts. Cast operators in an integer constant expression
> shall only convert arithmetic types to integer types, except as part of
> an operand to the sizeof or _Alignof operator.