[Bug c++/96934] Copy initialization of struct involving aggregate array initialization miscompiles in GCC 9
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96934 --- Comment #1 from Gustaw Smolarczyk --- It seems that part of this issue was already reported in another bug report (though the report is about flexible array members, the comment does not reference them): https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91490#c6 However, I don't see any mention of the miscompilation in the thread. Possibly the issue didn't surface in comment 6 as the tested string has only a single character (+ the terminating null character). Or strcmp is needed in order to trigger it.
[Bug c++/96934] Copy initialization of struct involving aggregate array initialization miscompiles in GCC 9
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96934 --- Comment #2 from Andrew Pinski --- Testcase: #include struct Code { constexpr Code(int) noexcept : _buffer{'1', '2', '\0'} {} char _buffer[3]; }; const Code T1 = {1}; const Code T2 = Code{1}; const Code T3 = T1; const Code T4 = T2; const Code T5{1}; const Code T6 = T5; #define TEST T1 int foo(const char* x) { return std::strcmp(TEST._buffer, x); } size_t bar() { return std::strlen(TEST._buffer); }