public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94716] New: Address of constexpr variable not usable in constant expression
@ 2020-04-22 15:36 bluescarni at gmail dot com
  2020-04-23  5:14 ` [Bug c++/94716] " marxin at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: bluescarni at gmail dot com @ 2020-04-22 15:36 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-01-06 16:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-22 15:36 [Bug c++/94716] New: Address of constexpr variable not usable in constant expression bluescarni at gmail dot com
2020-04-23  5:14 ` [Bug c++/94716] " marxin at gcc dot gnu.org
2021-08-28 22:27 ` [Bug c++/94716] comparison of address of template variables should be constexpr pinskia at gcc dot gnu.org
2021-09-10 22:46 ` johelegp at gmail dot com
2021-12-28 10:40 ` pinskia at gcc dot gnu.org
2022-01-03 12:48 ` cvs-commit at gcc dot gnu.org
2022-01-04 19:15 ` ppalka at gcc dot gnu.org
2022-01-06 16:17 ` ppalka at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).