Alex Rivera | Logout

What does this expression mean, and why does it compile?

Asked 2013-07-25T12:48:49.590
52

After a typo, the following expression (simplified) compiled and executed:

if((1 == 2) || 0 (-4 > 2))
  printf("Hello");

of course, the 0 shouldn't be there.

Why does it compile, and what does the expression mean?

The original (simplified) should look like this:

if((1 == 2) || (-4 > 2))
  printf("Hello");

none of this does compile:

if((1 == 2) || true (-4 > 2))
  printf("Hello");

if((1 == 2) || 1 (-4 > 2))
  printf("Hello");

if((1 == 2) || null (-4 > 2))
  printf("Hello");
Edit
Report

1 Answer

14

Guess it was interpreted as

if((1 == 2) || NULL (-4 > 2))
  printf("Hello");

where NULL is a function-pointer, by default returning int... What at actually happens in runtime is platform-dependent

answered 2013-07-25T12:53:19.317

Your Answer