https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115965
Bug ID: 115965 Summary: Stack smashing depending on order of declaration Product: gcc Version: 14.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: nathan.teodosio at canonical dot com Target Milestone: --- If I execute the binary I get ---> % ./e *** stack smashing detected ***: terminated Aborted (core dumped) <--- However, no error is raised if I swap lines 17 (where a and b are declared) and 18 (where c is declared), or if I move either a or b definition to after c. Valgrind says: ---> % valgrind -s --track-origins=yes --leak-check=full --show-leak-kinds=all ./e ==173999== Memcheck, a memory error detector ==173999== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al. ==173999== Using Valgrind-3.22.0 and LibVEX; rerun with -h for copyright info ==173999== Command: ./e ==173999== ==173999== Conditional jump or move depends on uninitialised value(s) ==173999== at 0x1092FA: main (in /tmp/e) ==173999== Uninitialised value was created by a stack allocation ==173999== at 0x109244: main (in /tmp/e) ==173999== *** stack smashing detected ***: terminated ==173999== ==173999== Process terminating with default action of signal 6 (SIGABRT): dumping core ==173999== at 0x4928B1C: __pthread_kill_implementation (pthread_kill.c:44) ==173999== by 0x4928B1C: __pthread_kill_internal (pthread_kill.c:78) ==173999== by 0x4928B1C: pthread_kill@@GLIBC_2.34 (pthread_kill.c:89) ==173999== by 0x48CF26D: raise (raise.c:26) ==173999== by 0x48B28FE: abort (abort.c:79) ==173999== by 0x48B37B5: __libc_message_impl.cold (libc_fatal.c:132) ==173999== by 0x49C0C18: __fortify_fail (fortify_fail.c:24) ==173999== by 0x49C1EA3: __stack_chk_fail (stack_chk_fail.c:24) ==173999== by 0x109300: main (in /tmp/e) ==173999== ==173999== HEAP SUMMARY: ==173999== in use at exit: 0 bytes in 0 blocks ==173999== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==173999== ==173999== All heap blocks were freed -- no leaks are possible ==173999== ==173999== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) ==173999== ==173999== 1 errors in context 1 of 1: ==173999== Conditional jump or move depends on uninitialised value(s) ==173999== at 0x1092FA: main (in /tmp/e) ==173999== Uninitialised value was created by a stack allocation ==173999== at 0x109244: main (in /tmp/e) ==173999== ==173999== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) Aborted (core dumped) <---