https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111904
Bug ID: 111904 Summary: Miscompilation with -O3 -fharden-control-flow-redundancy? Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: sjames at gcc dot gnu.org CC: aoliva at gcc dot gnu.org Target Milestone: --- Created attachment 56161 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56161&action=edit memset_explicit-gone-wrong.tar.xz Needs a trunk build from today or newer for -fharden-control-flow-redundancy. 1. git clone https://git.savannah.gnu.org/git/gnulib.git 2. ./gnulib-tool --single-configure --conditional-dependencies --create-testdir --dir=uhoh memset_explicit 3. cd uhoh 4. ./configure CFLAGS="-O3 -fharden-control-flow-redundancy" # passes with -O2 5. make TESTS=test-memset_explicit check -j$(nproc) ``` $ ./test-memset_explicit test_heap: address range is still mapped after free(). test_stack: count = 1000 test-memset_explicit.c:191: assertion 'count < 50' failed Aborted (core dumped) ``` I'm not sure where it goes wrong yet. Attached memset_explicit-gone-wrong.tar.xz has uhoh-O2 (good) and uhoh-O3 (bad) for x86_64, but I reproduced this on arm64 too.