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

            Bug ID: 95307
           Summary: Compiler accepts reinterpret_cast in constexpr
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vincent.hamp at higaski dot at
  Target Milestone: ---

The following snippet allows using reinterpret_casts inside a constexpr.

#include <cstdint>
uint64_t v;
constexpr auto p{reinterpret_cast<uint64_t>(&v) - 1u};

Compiled with GCC 10.1 and 9.3 with -std=c++2a


Interestingly subtracting 0u results in an error.

Reply via email to