[Bug c++/69433] missing -Wreturn-local-addr assigning address of a local to a static
glisse at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Aug 26 22:31:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69433
--- Comment #3 from Marc Glisse <glisse at gcc dot gnu.org> ---
f3: the inliner silently removes s (and the assignment to it) as write-only.
You need to add a function that reads s (we don't warn in that case either, of
course, but that's a first step).
f2: the (atomic) initialization of the static is a lot of hard to optimize
code. Still, since we manage to warn for f1:
# iftmp.0_1 = PHI <&a(2), "def"(3)>
a ={v} {CLOBBER};
return iftmp.0_1;
we would probably manage it for f2:
# prephitmp_14 = PHI <pretmp_12(3), &a(6), pretmp_13(5)>
a ={v} {CLOBBER};
return prephitmp_14;
... if there was an isolate-path pass after PRE, since before that we only see:
s = &a;
__cxa_guard_release (&_ZGVZ2f2vE1s);
<bb 5> [100.00%] [count: INV]:
_10 = s;
a ={v} {CLOBBER};
return _10;
IMO we should look into why this optimization doesn't happen before PRE (why
not FRE for instance?).
More information about the Gcc-bugs
mailing list