Bug 102551 - Failing compile-time comparison of std::type_info addresses
Summary: Failing compile-time comparison of std::type_info addresses
Status: RESOLVED DUPLICATE of bug 103600
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 12.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid, wrong-code
Depends on:
Blocks: constexpr
  Show dependency treegraph
 
Reported: 2021-10-01 08:03 UTC by Fedor Chelnokov
Modified: 2022-01-06 14:49 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.6.4
Last reconfirmed: 2021-10-01 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fedor Chelnokov 2021-10-01 08:03:38 UTC
The following valid code is rejected by GCC:
```
#include <typeinfo>

int main() {
    constexpr auto v1 = &typeid(int);
    constexpr auto v2 = &typeid(char);
    static_assert( v1 != v2 );
} 
```
Demo: https://gcc.godbolt.org/z/eexj7vcPG
Comment 1 Andrew Pinski 2021-10-01 08:13:31 UTC
It has always been broken since C++11 support was added:
#include <typeinfo>
static_assert( &typeid(int) != &typeid(char) ,"");
Comment 2 Patrick Palka 2022-01-06 14:49:04 UTC
Let's call this a dup of the recently fixed PR103600

*** This bug has been marked as a duplicate of bug 103600 ***