https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121478
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|tree-optimization |c
Status|NEW |ASSIGNED
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I am going to try to solve this tomorrow.
cp_fold does:
```
/* decltype(nullptr) has only one value, so optimize away all comparisons
with that type right away, keeping them in the IL causes troubles for
various optimizations. */
if (COMPARISON_CLASS_P (org_x)
&& TREE_CODE (TREE_TYPE (op0)) == NULLPTR_TYPE
&& TREE_CODE (TREE_TYPE (op1)) == NULLPTR_TYPE)
{
switch (code)
{
case EQ_EXPR:
x = constant_boolean_node (true, TREE_TYPE (x));
break;
case NE_EXPR:
x = constant_boolean_node (false, TREE_TYPE (x));
break;
default:
gcc_unreachable ();
}
return omit_two_operands_loc (loc, TREE_TYPE (x), x,
op0, op1);
}
```
And a few other things happen in the C++ front-end:
like in decay_conversion:
```
if (NULLPTR_TYPE_P (type) && !TREE_SIDE_EFFECTS (exp))
{
mark_rvalue_use (exp, loc, reject_builtin);
return nullptr_node;
}
```
Or in convert_arg_to_ellipsis:
```
else if (NULLPTR_TYPE_P (arg_type))
{
arg = mark_rvalue_use (arg);
if (TREE_SIDE_EFFECTS (arg))
{
warning_sentinel w(warn_unused_result);
arg = cp_build_compound_expr (arg, null_pointer_node, complain);
}
else
arg = null_pointer_node;
}
```