[Bug middle-end/85652] -Wformat-overflow warning silenced by -fpic/-fPIC

2018-05-07 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85652

Martin Sebor  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 CC||msebor at gcc dot gnu.org
 Resolution|--- |INVALID

--- Comment #2 from Martin Sebor  ---
As explained in comment #1, with -fpic extern functions are not considered
candidates for inlining because they can be superimposed.  Without -fpic GCC
sees that the inlined function can return a string that's as long as 55
characters but with the option a superimposed implementation could be
guaranteed to return a shorter string.  The same effect can be seen with other
middle-end warnings, including for example -Warray-bounds with the following
modified test case:

struct b
{
  const char *h(int) const;
  char c[4][56];
};

const char *b::h(int d) const
{
  return c[d];   // no -Warray-bounds with -fpic
}

void f() {
  b a;
  __builtin_puts (a.h (99));
}

[Bug middle-end/85652] -Wformat-overflow warning silenced by -fpic/-fPIC

2018-05-04 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85652

--- Comment #1 from Andrew Pinski  ---
I suspect this is due to inlining decision of b::h into f.  In PIC mode, b::h
is consider overwritable so it is not inclined while in non pic mode it is
inlined.