[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c74cad7b-9ea3-5223-8292-3fe1172a9419@mkarcher.dialup.fu-berlin.de>
Date: Sun, 22 Jan 2023 12:33:41 +0100
From: Michael Karcher <kernel@...rcher.dialup.fu-berlin.de>
To: Randy Dunlap <rdunlap@...radead.org>, linux-kernel@...r.kernel.org,
linux-sh@...r.kernel.org,
Segher Boessenkool <segher@...nel.crashing.org>,
Rich Felker <dalias@...c.org>,
Yoshinori Sato <ysato@...rs.sourceforge.jp>,
John Paul Adrian Glaubitz <glaubitz@...sik.fu-berlin.de>
Cc: jakub@....gnu.org
Subject: Re: [PATCH: 1/1] sh4: avoid spurious gcc warning
Am 22.01.2023 um 08:00 schrieb Randy Dunlap:
>> -#define _INTC_ARRAY(a) a, __same_type(a, NULL) ? 0 : sizeof(a)/sizeof(*a)
>> +#define _INTC_ARRAY(a) a, sizeof(a)/(_Generic((a), typeof(NULL): 0xFFFFFFFFU, default: sizeof(*a)))
> s/: / : / in 2 places.
>
> Tested-by: Randy Dunlap <rdunlap@...radead.org> # build-tested
Thanks for your confirmation! Are you sure about the space before the
colon? The colon in this case terminates a case descriptor for the
type-level switch construction using "_Generic". It says: "In case 'a'
has the 'type of NULL', divide by 0xFFFFFFFFU, in all other cases,
divide by the size of a single array element". It's not a colon of the
ternary ?: operator, in which case I would agree with the space before it.
If you confirm that you want a space before the colon in this case as
well, I'm going to add it, though.
> How far back in gcc versions does this work?
I tested the support of _Generic on Compiler Explorer at godbolt.org.
This construction is rejected by gcc 4.8, but accepted by gcc 4.9.
Kind regards,
Michael Karcher
Powered by blists - more mailing lists