sizeof( function )
Segher Boessenkool
segher@kernel.crashing.org
Tue Jun 12 17:47:00 GMT 2007
>> It is invalid to use sizeof() with a function
>> type expression (C99 '6.5.3.4 para. 1) and hence this code invokes
>> undefined behavior. gcc gives a warning if you compile with
>> -pedantic,
>> but otherwise it apparently just returns 1;
> But this is actually a BUG in gcc - look at 5.1.1.3. The restriction
> that sizeof may not have an argument that is function type is a
> constraint, and therefore a breach requires a diagnostic.
There is no bug, as GCC prints a diagnostic just fine.
That's what -pedantic is for.
Segher
More information about the Gcc-help
mailing list