https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113919
Bug ID: 113919
Summary: Nested anonymous unions should be prohibited in ISO
C++
Product: gcc
Version: 13.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: tsqurt at outlook dot com
Target Milestone: ---
Created attachment 57425
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57425&action=edit
example.cpp
Anonymous unions shall not be declared within an anonymous union. But gcc never
warns about this.
Demo source code as a C++17 source file attached. Note: attached code is a
valid C
source code but not a valid C++ source code. GCC is expected to REJECT or WARN,
but it compiles without any message.
$gcc example.cpp -std=c++17 --pedantic -Wall -Wextra
expect:
warning: ISO C++ prohibits anonymous unions within anonymous unions[-Wpedantic]
But gcc exited with code 0, leaving empty message.
Reference: N4849, Working Draft, Standard for Programming Language C++, Chapter
11, Section 5.1 Anonymous unions. (Different versions of modern C++
specification mention this issue in their correspondent chapters.)