https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110925
Bug ID: 110925 Summary: Unnecessary dynamic initialization in trivial cases Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: janschultke at googlemail dot com Target Milestone: --- ## Code to Reproduce int z = 0; int x = z; ## Expected Output (delivered by clang trunk -O3) x: .zero 4 z: .zero 4 ## Actual Output (x86_64 GCC 14 -O3) (https://godbolt.org/z/95d9hj3he) _GLOBAL__sub_I_z: mov eax, DWORD PTR z[rip] mov DWORD PTR x[rip], eax ret x: .zero 4 z: .zero 4 ## Explanation The implementation is allowed to turn this into static initialization. See https://eel.is/c++draft/basic.start.static#3. However, GCC emits unnecessary dynamic initialization code.