GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
testsuite

testsuite: Make g++.dg/torture/pr128147.C pass on Arm by reordering loads.

Testcase pr128147 now passes on Arm by reordering instructions to avoid a trapping load at function entry.

A GCC testcase (g++.dg/torture/pr128147.C) was failing on Arm architectures at optimization level -O1 due to a trapping load instruction occurring at the very beginning of a function. This caused an issue with exception handling during unwinding. The fix modifies the testcase by loading the pointer through an intermediate variable first, ensuring the trapping load is no longer the initial instruction. This change allows the test to pass on Arm without altering the generated code’s correctness, as reported in PR128147.

In Details

On Arm, specifically with -fnon-call-exceptions and -O1, a function f could begin with a ldr r0, [r0] instruction. If this load caused a fault, the unwind mechanism (get_eit_entry) would subtract 2 from the return address before lookup. This could lead to an incorrect unwind table lookup, propagating the exception to the wrong function. The fix reorders the load to ldr r3, [r0]; ldr r0, [r3], ensuring the faulting load is not the function's first instruction at -O1, thus passing the test for PR128147.

For Context
testsuite
A collection of tests used to verify the correctness of a software system, in this case, the GCC compiler.
trapping load
A memory load instruction that, if it causes an error (e.g., segmentation fault), triggers a hardware exception or trap.
exception handling
The mechanism by which a program responds to runtime errors or exceptional conditions.
unwinding
The process of traversing the call stack to find an exception handler when an exception is thrown.
Arm
A family of reduced instruction set computer (RISC) architectures commonly used in mobile devices and embedded systems, also increasingly in servers and laptops.
Filed Under: testsuitearmexception handlingbugfix