[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] _Generic or __builtin_choose_expr
From: |
uso ewin |
Subject: |
Re: [Tinycc-devel] _Generic or __builtin_choose_expr |
Date: |
Tue, 4 Jul 2017 17:59:49 +0200 |
Hi
I've push a new version that use skip_or_save_block from mob:
https://github.com/cosmo-ray/tcc/commits/mob
I've let the patch that change ex1.c that I used as testing so you can
see my ugly tests.
On Tue, Jul 4, 2017 at 4:46 PM, Michael Matz <address@hidden> wrote:
> 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 ;)
>
Well, I've just test
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;
}
- 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, 2017/07/04
- Re: [Tinycc-devel] _Generic or __builtin_choose_expr,
uso ewin <=
- 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