https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104031
Bug ID: 104031 Summary: [12 regression] Global nested constructors generate invalid code. Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: slyfox at gcc dot gnu.org Target Milestone: --- Extracted from original example of nix-2.4 where global constructors register invalid primops. Single-file example: // $ cat main.cc #include <string> #include <vector> struct Info { std::vector<std::string> args; size_t arity = 0; }; struct RegisterPrimOp { RegisterPrimOp(Info && info) __attribute__((noipa, noinline)) { if (info.arity != 0) __builtin_trap(); } }; static RegisterPrimOp s_op({ .args = {"path"}, .arity = 0, }); int main() {} # ok: $ g++-11.2.0 main.cc -o main -O2 && ./main # bad: $ g++-12.0.0 main.cc -o main -O2 && ./main Illegal instruction (core dumped) Using built-in specs. COLLECT_GCC=/<<NIX>>/gcc-12.0.0/bin/g++ COLLECT_LTO_WRAPPER=/<<NIX>>/gcc-12.0.0/libexec/gcc/x86_64-unknown-linux-gnu/12.0.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: Thread model: posix Supported LTO compression algorithms: zlib gcc version 12.0.0 20220109 (experimental) (GCC) Must be a recent regression. Possibly a close sibling of diagnostic false positive: https://gcc.gnu.org/PR103984