Messages in this thread |  | | Date | Sun, 22 Jan 2023 12:33:41 +0100 | Subject | Re: [PATCH: 1/1] sh4: avoid spurious gcc warning | From | Michael Karcher <> |
| |
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@infradead.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
|  |