This is the mail archive of the gcc-patches@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]

Re: [PATCH, C] Fix format warnings


> Richard Guenther writes:
> This patch makes the C frontend not warn that a format string
> is not literal for things like
> 
>   char *a = "Foo";
>   printf(&a[0]);
> 
> This will trigger everywhere in the format testsuite if the
> C frontend starts emitting array-to-pointer decay as &a[0].
> 
> Compiled and tested on i686-unknown-linux for C.
> 
> Ok for mainline?

??? But of course it should, as it's referencing a literal character value.
which can't be portably modified as it's a static const READONLY object.

In general the problem seems to be that GCC is not properly
identifying, allocating and treating  "string literals" as
a "static const char[]", as it likely should.

Why is/should it presumed otherwise?



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