On trunk, PR101592 was fixed by r12-2537, but that change shouldn't be
backported to GCC 11. In the PR Jakub suggested this fix, so here it
is, after the usual testing.
PR c++/101592
gcc/ChangeLog:
* fold-const.c (make_range_step): Return NULL_TREE for NULLPTR_TYPE.
gcc/testsuite/ChangeLog:
* g++.dg/warn/Wlogical-op-3.C: New test.
Co-authored-by: Jakub Jelinek <jakub@redhat.com>
being not equal to zero; "out" is leaving it alone. */
if (low == NULL_TREE || high == NULL_TREE
|| ! integer_zerop (low) || ! integer_zerop (high)
- || TREE_CODE (arg1) != INTEGER_CST)
+ || TREE_CODE (arg1) != INTEGER_CST
+ || TREE_CODE (arg0_type) == NULLPTR_TYPE)
return NULL_TREE;
switch (code)
--- /dev/null
+// PR c++/101592
+// { dg-do compile { target c++11 } }
+// { dg-options "-O2 -Wlogical-op" }
+
+decltype(nullptr) foo ();
+
+bool
+bar ()
+{
+ return foo () > nullptr
+ || foo () < nullptr;
+}