This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/69433] missing -Wreturn-local-addr assigning address of a local to a static


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?).

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]