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

            Bug ID: 71537
           Summary: GCC rejects consetxpr boolean conversions and
                    comparisons on the result of pointer arithmetic.
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eric at efcs dot ca
  Target Milestone: ---

For example:

constexpr int n[42] = {1};
constexpr int x = n ? 1 : 0; // Accepted.
constexpr int xx = n + 1 ? 1 : 0; // Rejected
constexpr int xxx = "abc" + 1 ? 1 : 0; // Also Rejected

This has a significant impact on constexpr algorithms which operate over raw
pointers since pointer comparisons are not considered constant expressions.

For example this bug breaks libc++'s implementation of string_view::find and
renders the "char_traits<char>::find(...)" interface useless since it returns a
possibly null pointer.

Reply via email to