[ros-dev] gcc problem or not

Hartmut Birr hartmut.birr at gmx.de
Wed May 4 01:22:21 CEST 2005


Thomas Weidenmueller wrote:

> Hartmut Birr wrote:
>
>> You are right, but I've still assumed that the pointer is zero or valid.
>> The real problem is, that gcc doesn't stop to validate an expression if
>> the result is determined and if the expression consist of simple
>> expressions which are combined with OR.
>
>
> 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;
> }
> _______________________________________________
> Ros-dev mailing list
> Ros-dev at reactos.com
> http://reactos.com:8080/mailman/listinfo/ros-dev
>
>
This means, gcc is intelligent enough to made a difference between
comparing a variable with different values and between calculating
expressions from pointers.

- Hartmut


More information about the Ros-dev mailing list