[ros-dev] gcc problem or not

Phillip Susi psusi at cfl.rr.com
Tue May 3 19:40:18 CEST 2005


The C and C++ standards REQUIRE the logical operators to short-circuit, 
meaning that the left hand side of the || must be evaluated first, and 
then the right hand side is evaluated if and only if the left hand side 
evaluated as false. 

Your test should always print true, and never crash.  If it does, then 
the compiler is indeed, very broken. 

Thomas Weidenmueller wrote:

> i tried the following test application with various configurations of 
> gcc 4.0 and 3.4.2, but it appears to work correctly.
>
> #include <stdio.h>
>
> int main(int argc, char* argv[])
> {
>   volatile int *x = NULL;
>
>   if(x == NULL || *x == 0)
>   {
>      printf("true\n");
>   }
>   else
>   {
>      printf("false\n");
>   }
>   return 0;
> }
> _______________________________________________




More information about the Ros-dev mailing list