[Bug c++/88380] New: Sequence of not-explicitly initialised, initialised, variable length generates no initialiser
matt at godbolt dot org
gcc-bugzilla@gcc.gnu.org
Wed Dec 5 20:28:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88380
Bug ID: 88380
Summary: Sequence of not-explicitly initialised, initialised,
variable length generates no initialiser
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: matt at godbolt dot org
Target Milestone: ---
In the following code:
---
struct S {
char uninit;
char initialised = 11;
char variable[];
};
void test() {
extern void use(const S & p);
S p {};
use(p);
}
---
(Compiled with Wall Wextra; see https://gcc.godbolt.org/z/4ubhIM )
...no code to initialise "initialised" is generated. Commenting out any one of
the members causes structure initialisation to take place. Changing the
`variable` to be either zero-sized or not an array also causes initialisation
to take place.
The equivalent in clang always initialises.
I'm not sure whether this is expected, or not, but I would hope for either a
diagnostic if this is UB, or for it to be consistent when other memebers are
initialised.
More information about the Gcc-bugs
mailing list