Hi,
On Tue, 4 Jul 2017, grischka wrote:
> Michael Matz wrote:
> > First string literals are now always const char, ...
>
> Hm... ;)
>
> Actually the behavior with -Wwrite-strings that we had is what
> gcc has too:
>
> typeof("123") cc = "456";
> cc[1] = 'x';
> printf("%s\n", cc);
>
> $ gcc -Wno-write-strings ...
> 4x6
> $ gcc -Wwrite-strings ...
> error: assignment of read-only location 'cc[1]'
Ugh, you're right. Indeed the standard doesn't mandate a const char[]
type for string literals (I was confused because it does say that
modification of string literals is undefined, i.e. that's an extension).
Let me work on this a bit.
> (mingw gcc 3.4.2 and 6.3.0)
>
> Also, now tcc doesn't warn with this one anymore:
> const char cc[] = "456";
> char *p = cc;
Yeah, that was conscious on my part but still under the influence of the
above confusion ;-)
Ciao,
Michael.
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel