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

    <tr>
        <th>Summary</th>
        <td>
            odd behavior in std::map with an allocator with fancy pointers
        </td>
    </tr>

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

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

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

<pre>
    https://godbolt.org/z/xj63dcsGc
The point of the example is that `std::map` converts a raw pointer to a fancy pointer, when the raw pointer did not come from the allocator (it came from the stack)
This seems odd to me, a fancy pointer for a specific allocator is intended for memory related to that allocator (nullptr included)
The C++ standard, in the Cpp17Allocator requirement, specifies that `pointer_to(r)` has to work, but for specific references `r`, not all
Quoting:
* p denotes a value of type XX::pointer obtained by calling a1.allocate, where a1 == a
* r denotes a value of type T& obtained by the expression *p
* -only mention of pointer_to- pointer_traits<XX::pointer>::pointer_to(r) -- same as p

Current libc++ implementation of std::map then implies that fancy pointers HAVE to also be able to contain unrelated addresses, which restricts certain (in my opinion reasonable) usecases, for example offset pointers for <4GB fixed memory, containing a 32bit offset
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0VE-P4rgT_TTmUqJlbAj0IQeaHuZ3_Umj1dxWFbtCPOPYWdvpbubTryqEBlraC8R21atXr_5gzu4UiGqxeRGb1wWOpYupdh7_YHJm0UR7rrtShiz0XqijUMdTtE305Smmk1DHP0IdP35V2pr83Qj5KuT-R0cwRBcKxBZKR0Af2A-ewGUoHRYQlczFMqDe9ziISoKJ4Y1SyYCQ8P3iTglKBIQWgzlfr4Q6wHtHYQK-N7XOQogFTOwJ2hT7yQK9jwZLTCDUzhUweP-aC5rfQj1febsMmajPEK3l2D1xuC8MoI0JEPJAxrXO3IVwGdgiWLKTUU99TGdI5LHQBDil_8ApjN4PJYELxo-W7B0bgoNQL0K9MM9gMV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