tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] _Generic or __builtin_choose_expr


From: Michael Matz
Subject: Re: [Tinycc-devel] _Generic or __builtin_choose_expr
Date: Tue, 4 Jul 2017 16:27:39 +0200 (CEST)
User-agent: Alpine 2.20 (LSU 67 2015-01-07)

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]