Checking the name
Checking the name
Posted Jun 20, 2022 13:51 UTC (Mon) by khim (subscriber, #9252)In reply to: Checking the name by NYKevin
Parent article: A new LLVM CFI implementation
> It's a shame the standard doesn't let you write something like "void" for a zero-size argument.
Well… zero-sized arguments don't exist in standard C, they are GNU extension which means you can try to supply the patch which will support what you want to Clang and GCC.
Once you left the standard it's kind of hard to expect to see such non-standard constructs supported in said standard, don't you think?
Posted Jun 20, 2022 17:39 UTC (Mon)
by nybble41 (subscriber, #55106)
[Link] (1 responses)
A keyword for the void constructor might be nice, but "(void)0" would serve well enough. This could be made into a standard VOID macro, like NULL for "(void*)0".
Posted Jun 20, 2022 20:56 UTC (Mon)
by wahern (subscriber, #37304)
[Link]
Also, at least based on a straight-forwarding reading of the standard, sequentially declared 0-length bit fields should collapse (i.e. not unspecified or undefined behavior), so that they introduce only one word of padding at most, if any; and this is indeed the behavior I see from clang and GCC. And while maybe more susceptible to disagreement, the language of the standard does seem to specify that a 0-length bit field not succeeding another bit field should not introduce any padding. I see the same behaviors for 0-length arrays, but the GCC documentation seemed much more ambiguous on both points.[2]
I am curious why I haven't seen void (the true "nothing") type semantics extended elsewhere in the grammar. Maybe 0-length bit and array fields were sufficient, if not ideal, for the most pressing scenarios. But perhaps the language (inclusive of extensions) is finally moving in a direction where the old hacks are insufficient, and void might see some more attention.
[1] See $ 3.5.2.1 at http://port70.net/~nsz/c/c89/c89-draft.txt
[2] Putting it all together after having double checked my assertions with the standard, it does seem that the only use for 0-length arrays has been almost entirely subsumed by flexible array members, except that the former make indexing notation easier (no offsetof verbiage). For anything else (mostly in relation to extensions, like 0-length structures), 0-length bit field notation seems sufficient. Maybe the situation is different with C++.
Checking the name
Checking the name