News for hackers. Stuff that matters.
Re:“That is either genius, or a seriously diseased mind.” – ... by roelschroeven on Friday August 30, 2019 @05:09AM (#20836936)
In that post Linus says something I don't understand in that post:

"... So with a constant, we have

  sizeof( 1 ? NULL : (int *) 1)
  
and the rule is that if one of the sides of a ternary operation with pointers is NULL, the end result is the other type (int *)."

Is Linus saying that the condition of the ternary operation doesn't matter if one of the sides is NULL? That it then always evaluates to the other side? That's not what happens when I try it. Or are there special rules when sizeof is applied?

Re:“That is either genius, or a seriously diseased mind.” – ... by roelschroeven on Friday August 30, 2019 @05:11AM (#20836954)
Oh, I get it now: Linus wasn't talking about the values, but about the types. In this case, the result will be a NULL pointer of type (int *).

Sorry, nothing to see here.

Re:“That is either genius, or a seriously diseased mind.” – ... by cbsks on Saturday August 31, 2019 @10:31AM (#20846496)
I just had the same confusion. Thanks for figuring it out so I didn’t have to!
Re:“That is either genius, or a seriously diseased mind.” – ... by rurban on Friday August 30, 2019 @10:15AM (#20838793)
I really need this for libc optimizations. So far it only worked in C++ mode or newer clang's, but not in gcc.
Re:“That is either genius, or a seriously diseased mind.” – ... by msarnoff on Friday August 30, 2019 @04:03PM (#20842116)
Isn't this what GCC's `__builtin_constant_p()` does?