sizeof( function )
Nick Maclaren
nmm1@cus.cam.ac.uk
Thu Jun 14 13:14:00 GMT 2007
"Martin Krischik" <krischik@users.sourceforge.net> wrote:
>
> If it is invalid to use sizeof() with a function type expression - why not
> an make it an compile time error?
That is what most compilers do. However, gcc allows pointer arithmetic
on function pointers, to enable C code to poke through compiled code
(e.g. to disassemble code). Given how few programmers ever do that
sort of thing, it could perfectly well issue a warning even without
-pedantic. But it doesn't.
Note that, for C language reasons, it is virtually impossible to
separate the handling of sizeof(<type>) from allowing arithmetic on
values of type '<type> *'.
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
More information about the Gcc-help
mailing list