https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91554

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
It's obviously

8462   /* If this expression has side effects, show we don't know it to be a
8463      constant.  Likewise if it's a pointer or aggregate type since in
8464      those case we only want literals, since those are only optimized
8465      when generating RTL, not later.
8466      And finally, if we are compiling an initializer, not code, we
8467      need to return a definite result now; there's not going to be any
8468      more optimization done.  */
8469   if (TREE_SIDE_EFFECTS (arg)
8470       || AGGREGATE_TYPE_P (TREE_TYPE (arg))
8471       || POINTER_TYPE_P (TREE_TYPE (arg))
8472       || cfun == 0
8473       || folding_initializer
8474       || force_folding_builtin_constant_p)
8475     return integer_zero_node;

that causes this, I guess you want to use

__builtin_constant_p (b != 0)

instead.  The docs don't explain what a "constant at compile time" is
so whether for example the address of a global or the address of an
automatic var would be "constant".  But I'd say the above incorrectly
disregards the NULL-pointer case.

Reply via email to