With -O2 optimization enabled, GCC 15 and 16 have been shown to create corrupted compilations. Discussions on Debian bug and mailing lists:
Known working versions/options:
- This issue has not been observed on GCC 14 or earlier.
- If using GCC 15 but with the
-O1 flag, the issue does not happen.
A minimalist code snippet (can be saved as a file conftest.cc):
/* If GCC 3.4.6 is compiled with GCC 15 and the -O2 flag,
* compilation of this snippet by GCC 3.4.6 will fail.
* If, however, GCC 3.4.6 is compiled with GCC 15 and the -O1 flag,
* (or GCC 14 and earlier, even with the -O2 flag)
* compilation of this snippet by GCC 3.4.6 succeeds.
*/
struct S { ~S(); };
void bar();
void foo()
{
S s;
bar();
}
Compilation Command:
/mnt/shared/src/GitHub.com/BrickBot/GNU-Legacy-Toolchain/build/suse/gcc3-O2/gcc3/gcc/xgcc -shared-libgcc -B/mnt/shared/src/GitHub.com/BrickBot/GNU-Legacy-Toolchain/build/suse/gcc3-O2/gcc3/gcc/ -nostdinc++ -L/mnt/shared/src/GitHub.com/BrickBot/GNU-Legacy-Toolchain/build/suse/gcc3-O2/gcc3/h8300-hitachi-coff/libstdc++-v3/src -L/mnt/shared/src/GitHub.com/BrickBot/GNU-Legacy-Toolchain/build/suse/gcc3-O2/gcc3/h8300-hitachi-coff/libstdc++-v3/src/.libs -nostdinc -B/mnt/shared/src/GitHub.com/BrickBot/GNU-Legacy-Toolchain/build/suse/gcc3-O2/gcc3/h8300-hitachi-coff/newlib/ -isystem /mnt/shared/src/GitHub.com/BrickBot/GNU-Legacy-Toolchain/build/suse/gcc3-O2/gcc3/h8300-hitachi-coff/newlib/targ-include -isystem /mnt/shared/src/GitHub.com/BrickBot/GNU-Legacy-Toolchain/sym-combined/gcc3/newlib/libc/include -B/opt/stow/h8300-hitachi-coff-gcc3/h8300-hitachi-coff/bin/ -B/opt/stow/h8300-hitachi-coff-gcc3/h8300-hitachi-coff/lib/ -isystem /opt/stow/h8300-hitachi-coff-gcc3/h8300-hitachi-coff/include -isystem /opt/stow/h8300-hitachi-coff-gcc3/h8300-hitachi-coff/sys-include -L/mnt/shared/src/GitHub.com/BrickBot/GNU-Legacy-Toolchain/build/suse/gcc3-O2/gcc3/ld -c -S -g -Os conftest.cc
The error message from the "GCC 15 -O2"-built GCC 3.4.6 with the debug decl.c (c.f. below) is as follows:
conftest.cc:1: error: Current decl type: void
…
conftest.cc:1: confused by earlier errors, bailing out
There could be other issues caused by GCC 15; this is just one that has been identified thus far. There are potentially at least two other cases noted on the Debian bug site (brickOS and sh4) [c.f. bug # 1121607].
Attached is that debug version of gcc-3.4.6/gcc/cp/decl.c that outputs extra info at the point of failure:
decl.c
Briefly, between the default: line and the my_friendly_assert (0, 20020917); line, this debug version adds the following (enum values are defined intree.h/tree.def):
error ("\
Current decl type: %T\n\
Found TREE_CODE: %d\n\
ERROR_MARK: %d\n\
IDENTIFIER_NODE: %d\n\
TREE_LIST: %d\n\
TREE_VEC: %d\n\
BLOCK: %d\n\
VOID_TYPE: %d\n\
COND_EXPR: %d\n\
BIT_NOT_EXPR: %d\n\
ADDR_EXPR: %d\n\
ARRAY_REF: %d\n\
INDIRECT_REF: %d\n\
CALL_EXPR: %d\n\
TEMPLATE_ID_EXPR: %d\n\
SCOPE_REF: %d\n\
TYPE_DECL: %d\n\
BASELINK: %d\n\
TEMPLATE_DECL: %d\n\
C++\n\
NAMESPACE_DECL: %d\n\
",
decl,
TREE_CODE (decl),
ERROR_MARK,
IDENTIFIER_NODE,
TREE_LIST,
TREE_VEC,
BLOCK,
VOID_TYPE,
COND_EXPR,
BIT_NOT_EXPR,
ADDR_EXPR,
ARRAY_REF,
INDIRECT_REF,
CALL_EXPR,
TEMPLATE_ID_EXPR,
SCOPE_REF,
TYPE_DECL,
BASELINK,
TEMPLATE_DECL,
NAMESPACE_DECL );
With
-O2optimization enabled, GCC 15 and 16 have been shown to create corrupted compilations. Discussions on Debian bug and mailing lists:Known working versions/options:
-O1flag, the issue does not happen.A minimalist code snippet (can be saved as a file
conftest.cc):Compilation Command:
The error message from the "GCC 15 -O2"-built GCC 3.4.6 with the debug decl.c (c.f. below) is as follows:
There could be other issues caused by GCC 15; this is just one that has been identified thus far. There are potentially at least two other cases noted on the Debian bug site (brickOS and sh4) [c.f. bug # 1121607].
Attached is that debug version of
gcc-3.4.6/gcc/cp/decl.cthat outputs extra info at the point of failure:decl.c
Briefly, between the
default:line and themy_friendly_assert (0, 20020917);line, this debug version adds the following (enumvalues are defined intree.h/tree.def):