[lkml]   [2023]   [Jan]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [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 <> # 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
This construction is rejected by gcc 4.8, but accepted by gcc 4.9.

Kind regards,
  Michael Karcher

 \ /
  Last update: 2023-03-26 23:51    [W:0.125 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site