http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54582
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fweimer at redhat dot com
--- Comment #10 from Florian Weimer <fweimer at redhat dot com> 2013-02-06
14:28:35 UTC ---
(In reply to comment #9)
> 1) this is -D_FORTIFY_SOURCE warning, you can invent other warnings elsewhere
> 2) with -D_FORTIFY_SOURCE, e.g. sprintf is an inline function, so the FE sees
> it as a call to an inline function with some argument, you need to inline it,
> figure out what the inline does, then fold the builtins used in the inline.
> Also consider
> char buf[2];
> char *p;
> p = buf;
> sprintf(buf, "ab%d", n);
I think you mean sprintf(p, ...).
> Unless you move the optimization passes into the FE, you aren't going to warn
> about this properly in the FE. Insisting on a FE warning in this case is just
> dumb.
We could duplicate optimizations in the front end (like others do).
More seriously, I think this is a case where a layering violation makes perfect
sense.