[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:46:50 +0200 (CEST) |
User-agent: |
Alpine 2.20 (LSU 67 2015-01-07) |
Hi,
On Tue, 4 Jul 2017, Michael Matz wrote:
> 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.
Actually, not much need for work. I've checked GCC sources and, even
though it wonders in a comment if it's a good idea to change expression
types with warning flags, it indeed does so; so if for nothing else than
compatibility I've reverted the patch.
The hack in the current patch for _Generic (to regard string literals as
const char* always) isn't needed. GCC indeed differs in behaviour
depending on the warning flag, also in _Generic:
-----------------------
extern int printf(const char *,...);
int main()
{
const char *msg;
msg = _Generic("foo", const char *:"const char*", char*:"char *",
default:"something else");
printf ("type \"foo\" = %s\n", msg);
return 0;
}
-----------------------
% gcc-6 -Wwrite-strings x.c && ./a.out
type "foo" = const char*
% gcc-6 -Wno-write-strings x.c && ./a.out
type "foo" = char*
So, thanks for checking after me ;)
Ciao,
Michael.
- Re: [Tinycc-devel] _Generic or __builtin_choose_expr, uso ewin, 2017/07/03
- Re: [Tinycc-devel] _Generic or __builtin_choose_expr, Michael Matz, 2017/07/03
- Re: [Tinycc-devel] _Generic or __builtin_choose_expr, grischka, 2017/07/04
- Re: [Tinycc-devel] _Generic or __builtin_choose_expr, Michael Matz, 2017/07/04
- Re: [Tinycc-devel] _Generic or __builtin_choose_expr,
Michael Matz <=
- Re: [Tinycc-devel] _Generic or __builtin_choose_expr, uso ewin, 2017/07/04
- Re: [Tinycc-devel] _Generic or __builtin_choose_expr, uso ewin, 2017/07/04
- Re: [Tinycc-devel] _Generic or __builtin_choose_expr, uso ewin, 2017/07/04
- Re: [Tinycc-devel] _Generic or __builtin_choose_expr, Michael Matz, 2017/07/05
- Re: [Tinycc-devel] _Generic or __builtin_choose_expr, uso ewin, 2017/07/05
- Re: [Tinycc-devel] _Generic or __builtin_choose_expr, Christian Jullien, 2017/07/06
- Re: [Tinycc-devel] _Generic or __builtin_choose_expr, uso ewin, 2017/07/06
- Re: [Tinycc-devel] _Generic or __builtin_choose_expr, uso ewin, 2017/07/06