This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: sizeof( function )


> 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;
It's not quite that simple - look at footnote 84 :-(

Both function designators ('function names') and sizeof are weird,
in that they look like a value and a function, but aren't quite.

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.


Regards,
Nick Maclaren,
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QH, England.
Email:  nmm1@cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]