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

            Bug ID: 94716
           Summary: Address of constexpr variable not usable in constant
                    expression
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bluescarni at gmail dot com
  Target Milestone: ---

The following code does not compile in GCC trunk:

-----
template <typename T>
inline constexpr char test_impl = 0;

template <typename T>
inline constexpr auto *id = &test_impl<T>;

int main() {
    static_assert(id<int> != id<float>, "should not be equal");
}
-----

The error message:

-----
<source>: In function 'int main()':

<source>:8:27: error: non-constant condition for static assertion

    8 |     static_assert(id<int> != id<float>, "should not be equal");

      |                   ~~~~~~~~^~~~~~~~~~~~

<source>:8:27: error: '((& test_impl<int>) != (& test_impl<float>))' is not a
constant expression

Compiler returned: 1
-----

See on godbolt:

https://godbolt.org/z/CS4D8B

Clang and MSVC accept the code.

Reply via email to