https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99677
Bug ID: 99677 Summary: [[gnu::const]] attribute does not prevent dead global variable gets emitted. Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: unlvsur at live dot com Target Milestone: --- https://godbolt.org/z/Toncas The code tries to import functions from DLLs in the global. Clang does not generate the nt_create_file function pointer, GCC does. Even at -O0, clang emits no code. It only emits code any function actually uses it. That is super annoying for Windows since we have no way to invoke Windows NT syscalls without emitting dead code with GCC.