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

            Bug ID: 115617
           Summary: Wrong diagnostic message for non-const expr in
                    constexpr context
           Product: gcc
           Version: 13.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jengelh at inai dot de
  Target Milestone: ---

Input:

enum E { FOO = 2 };
int main()
{
  static constexpr auto x = reinterpret_cast<void *>(static_cast<long>(FOO));
  static constexpr auto y = reinterpret_cast<void *>(static_cast<long>(2));
}

Observed output:

$ g++ -c x.cpp -Wall -std=c++17
x.cpp: In function ‘int main()’:
x.cpp:4:29: error: ‘reinterpret_cast<void*>(2)’ is not a constant expression
x.cpp:5:29: error: ‘reinterpret_cast’ from integer to pointer

Expected output:

x.cpp: In function ‘int main()’:
x.cpp:4:29: error: ‘reinterpret_cast<void*>(2)’ is not a constant expression
x.cpp:5:29: error: ‘reinterpret_cast<void*>(2)’ is not a constant expression

Reply via email to