https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89990
--- Comment #7 from Andrew D'Addesio <modchipv12 at gmail dot com> --- (In reply to Andrew Pinski from comment #6) > The warning is now included in GCC 12. > And this makes this a dup of bug 63272. > > *** This bug has been marked as a duplicate of bug 63272 *** Yep, the new warning is working nicely on my test case (comment #5) on GCC 14.0.1 on Fedora 40 x86-64: test.c: In function ‘test’: test.c:22:15: warning: dangling pointer ‘ptr’ to an unnamed temporary may be used [-Wdangling-pointer=] 22 | return ptr->c; | ~~~^~~ test.c:15:37: note: unnamed temporary defined here 15 | ptr = &(const struct mytype){ 43 }; | ^ Though one thing to note -- (in addition to the above warning) it still generates that "strange" -Wuninitialized warning if and only if there are one or fewer calls to foo(): In function ‘test’, inlined from ‘main’ at test.c:27:12: test.c:22:15: warning: ‘<Ufe10>.c’ is used uninitialized [-Wuninitialized] 22 | return ptr->c; | ~~~^~~ ^ If foo() is called 2+ times then that warning disappears. It's not a bug per se as the "real" -Wdangling-pointer warning still gets displayed to the user (Ufe10 is probably GCC's representation of the variable that was never initialized). But I find it very peculiar that the threshold for silencing that -Wuninitialized warning is 2 function calls and not say 1 or 10. This actually has gotten me curious. Would you have an idea/explanation behind that 2 function call threshold @Andrew Pinski?