On 10/22/26 2:18 AM, Jonas Hansen via Sourceware Forge wrote:
From: Jonas Hansen <[email protected]>

With -ftrivial-auto-var-init, an anonymous temporary can be initialized
by an SSA name defined by .DEFERRED_INIT.  Inlining gives the destination
declaration a new DECL_UID while the call retains the original D.N name.
warn_uninit then fails to recognize the artificial initialization store
and diagnoses it as an uninitialized read.  This occurs, for example,
with a reference bound to a conversion temporary when ASan, UBSan and
-ftrivial-auto-var-init=zero are enabled.

Keep the existing current-UID comparison and also check DECL_ORIGIN when
recognizing this artificial store.  Add regression tests for zero and
pattern initialization.

gcc/ChangeLog:

        PR middle-end/124380
        * tree-ssa-uninit.cc (warn_uninit): Also match the original
        declaration's UID when recognizing the artificial initialization
        of an anonymous variable after inlining.

gcc/testsuite/ChangeLog:

        PR middle-end/124380
        * g++.dg/asan/auto-init-uninit-1.C: New test.
        * g++.dg/asan/auto-init-uninit-2.C: New test.

Signed-off-by: Jonas Hansen <[email protected]>
I think Richi probably needs to chime in here.  He ACK'd the original from Qing; I didn't even know this code existed and was about to reject based on using names to drive/filter in tree-ssa-uninit which seems rather hacky to me.

jeff

Reply via email to