This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


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: Is this expected gcc behaviour?


Jay Monkman <jtm-list-crossgcc@smoothsmoothie.com> writes:

> When I compile this function:
>      extern unsigned long ptr;
> 
>      int func(void)
>      {
>          unsigned long val = (unsigned long)&ptr;
> 
> 	 if (val == 0) {
> 	     return 1;
>          } else {
>              return 0;
>          }
>      }
> 
> with any optimization level > 0, I get this:
>     func:
>         clr.l %d0
>         rts

This behavior of gcc is correct.  The C standard guarantees that no
object can be located at address 0, i.e. the result of the address
operator on any object is always different from the null pointer.

urs

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


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