https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98901
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Last reconfirmed| |2021-01-31 CC| |msebor at gcc dot gnu.org See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=98900 Summary|Static analyses warning |missing warning passing a |disappears when the value |dangling pointer to a |is passed to a function |function |with variable number of | |arguments when optimisation | |is on | Status|UNCONFIRMED |NEW --- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> --- I think the problem here reduces to one of GCC having no support for detecting the uses of dangling pointers. In the original test case the variadic function is defined but because GCC doesn't inline variadic functions it's not relevant. The smaller test case below shows that after a variable's life has ended, using its address isn't diagnosed even though any and all uses of pointers to such objects are undefined. Diagnosing the use of such a pointer in this test case is trivial based on the preceding CLOBBER. (See also pr98900 for another test case involving clobbers.) $ cat pr98901.c && gcc -O2 -S -Wall -fdump-tree-uninit=/dev/stdout pr98901.c int f (int count, ...); int main () { int *p; { int x = 0; p = &x; } f (1, p); // missing warning __builtin_putchar (*p); } ;; Function main (main, funcdef_no=0, decl_uid=1944, cgraph_uid=1, symbol_order=0) (executed once) int main () { int x; int _1; <bb 2> [local count: 1073741824]: x ={v} {CLOBBER}; f (1, &x); _1 = x; __builtin_putchar (_1); return 0; }