<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/59790>59790</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Equal typeid for nonequal types in anonymous namespaces
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Alcaro
      </td>
    </tr>
</table>

<pre>
    ```c++
#include <typeinfo>

namespace {
        struct my_x {
                static int member;
        };
        int my_x::member;
}

int* get_member() { return &my_x::member; }
const std::type_info* inf() { return &typeid(my_x); }
```
```c++
#include <typeinfo>

namespace {
        struct my_x {
                static int member;
        };
        int my_x::member;
}

int* get_member();
const std::type_info* inf();

int* get_member2() { return &my_x::member; }
const std::type_info* inf2() { return &typeid(my_x); }

#include <stdio.h>

int main()
{
        printf("%p %p\n", get_member(), get_member2());
        printf("%p %p\n", inf(), inf2());
        printf("%d\n", get_member() == get_member2());
        printf("%d\n", *inf() == *inf2());
}
```
https://godbolt.org/z/Pjnz6jbGb

This prints four pointers, then 0 1.

I believe that is an illegal output. Either the two my_x are the same, and it should print 1 1, or they're different, and it should print 0 0. I think 0 0 is the correct answer, but I'm not very familiar with this corner of the C++ specification.

Similar to #10492 - that one's long gone, but maybe a similar fix would apply here. (GCC has a similar bug, but only with -flto -fmerge-all-constants.)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcVc9vq0YQ_muWy8gIFmPMgYOfHT_lVqm9RwsMsOmyS3eHOLy_vlpwHJK6r6nUUyUEml_ffvMNA8I52WrEgqXfWHoKxEidscVBVcKaoDT1VLBdtFwV49_8FZ1YdGA8kbpSY43AkiNNA0rdGJY8XMPzXYse3SAqBJa91UW5IztWBP309PrBP4cEyQqkJuixL9GyZBXPTmtzTpqeXllyYMnhc3p2WhORmhg_QIv0dE3ke8ZzfzxYpNFqYHx3B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