|
|
|
|
|
by ksherlock
3010 days ago
|
|
I didn't believe it would work but it does. It boils down to sizeof(int) == sizeof(void)
vs sizeof(int) == sizeof(int)
As a non-standard extension, in gcc (and thus clang and icc for compatibility, it seems) void has a size of 1. In a conforming compiler, it's an error. |
|
Gcc it didn't fold it during preprocessing for a fully constant expression, which is allowed. In which case always sizeof(void) is a valid answer. Which is a compile error.
That is at least what C99 draft seems to say.
I'll check C11 draft next. Edit: same.