https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107138
Colin Hirsch <gcc at cohi dot at> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gcc at cohi dot at
--- Comment #17 from Colin Hirsch <gcc at cohi dot at> ---
This bug is back in GCC 16.1.0 with -O3 and -fsanitize=undefined, or with -O3
and more complex code:
Compiling the code from the first comment with g++-16 -O3 -Wall -Wextra -Werror
-pedantic -fsanitize=undefined -std=c++20 on macOS with GCC 16.1.0 from
HomeBrew also gives a "may be used uninitialized" error.
Reducing the optimization level to -O2 makes the error go away.
Removing -fsanitize=undefined makes the error go away.
However more complex code can trigger the error even without
-fsanitize=undefined:
Compiling PEGTL main branch at commit e87b2d1912800682a699001ba3c2b622cb3e627c
with GCC 16.1.0 and g++-16 -std=c++20 -Iinclude -pedantic -Wall -Wextra
-Wshadow -Werror -O3 leads to the same error in heavily templated code
involving a std::variant with a std::string.
I have not been able to reproduce with code as small as the original example
here.
The PEGTL does compile with GCC 11, 12, 13, 14 with the GitHub actions,
presumably because it doesn't use -fsanitize=undefined and I'm not sure which
exact GCC 12 version is used.