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 )


"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


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