Re: Arithmetic on function address

From: Alex Fraser (me_at_privacy.net)
Date: 04/23/04


Date: Fri, 23 Apr 2004 22:03:09 +0100


"Stephen Biggs" <Spammers@AreLowLifes.com-INVALID-MUNGED> wrote in message
news:c6bjka$sct$1@news2.netvision.net.il...
> Given this code:
> void f(void){}
> int main(void){return (int)f+5;}
>
> Is there anything wrong with this in terms of the standards? Is this
> legal C code? One compiler I'm working with compiles this quietly, even
> with the most stringent and pedantic ANSI and warning levels, but
> generates code that only loads the address of "f" and fails to make the
> addition before returning a value from "main".

Perhaps it optimised the addition away by moving f() ;).



Relevant Pages

  • Re: new IL: C (sort of...).
    ... and the frontend compiler needs to be able ... Having very limited pointers is a fact of life in a VM language though, ... vague claims about Pascal's pointer support. ... That is pretty normal for standards (the ...
    (comp.lang.misc)
  • Re: Why not add namespace feature into standard C?
    ... features, I can't understand why not add this feature into standard C. ... Because the standards people were more concerned with adding arbitrary ... All the compiler vendors have balked. ...
    (comp.lang.c)
  • Re: SOURCEFORMAT AND COPY LIBRARY
    ... Jimmy? ... Oh that human communication problem! ... version of the compiler, ... I still LIKE YOU :-) - but you are very passionate about the Standards. ...
    (comp.lang.cobol)
  • Re: Testing ham radio software on Sun hardware.
    ... Is that like the way Micro$oft adheres to the W3C standards? ... It sometimes means code built with gcc will not compile on better compilers. ... The other issue is that people often write code that works on Linux, but makes use of Linux specific header files. ... If anyone has some open-source UNIX or Linux code they would like to test on a Sun, using a commercially produced C compiler, let me know. ...
    (uk.radio.amateur)
  • Re: Arithmetic on function address
    ... > void f ... > Is there anything wrong with this in terms of the standards? ... One compiler I'm working with compiles this quietly, ... That's a very odd way to examine the value of an integer expression. ...
    (comp.lang.c)