<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><span class="vcard"><a class="email" href="mailto:richard-llvm@metafoo.co.uk" title="Richard Smith <richard-llvm@metafoo.co.uk>"> <span class="fn">Richard Smith</span></a>
</span> changed
          <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - Unexpected constexpr assignment error relating to object lifetime and std::allocator"
   href="https://bugs.llvm.org/show_bug.cgi?id=47047">bug 47047</a>
          <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>NEW
           </td>
           <td>RESOLVED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>---
           </td>
           <td>INVALID
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - Unexpected constexpr assignment error relating to object lifetime and std::allocator"
   href="https://bugs.llvm.org/show_bug.cgi?id=47047#c1">Comment # 1</a>
              on <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - Unexpected constexpr assignment error relating to object lifetime and std::allocator"
   href="https://bugs.llvm.org/show_bug.cgi?id=47047">bug 47047</a>
              from <span class="vcard"><a class="email" href="mailto:richard-llvm@metafoo.co.uk" title="Richard Smith <richard-llvm@metafoo.co.uk>"> <span class="fn">Richard Smith</span></a>
</span></b>
        <pre>Your testcase has undefined behavior; GCC is wrong to accept it.
std::allocator<int>::allocate only allocates memory for the array of ints, it
does not start the lifetime of any int objects. You need to create an int
object using std::construct_at before you can assign to it:

  std::allocator<int> alloc;
  int *p = alloc.allocate(1);
  std::construct_at(p);
  *p = 42;
  int i = *p;
  alloc.deallocate(p,1);

Then GCC and Clang both accept: <a href="https://godbolt.org/z/8j9Kas">https://godbolt.org/z/8j9Kas</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>