https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119754

Tomasz Kamiński <tkaminsk at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
                 CC|                            |tkaminsk at gcc dot gnu.org
   Last reconfirmed|                            |2025-04-15

--- Comment #2 from Tomasz Kamiński <tkaminsk at gcc dot gnu.org> ---
The `clang` is right here, because allocator<int>::allocate() is specified to
start lifetime of array, but not it's elements
https://eel.is/c++draft/memory#allocator.members-5:
> This function starts the lifetime of the array object, but not that of any of 
> the array elements.

However, our implementation just call `::operator new`, that starts lifetime of
both array and it's elements:
```
      [[nodiscard,__gnu__::__always_inline__]]
      constexpr _Tp*
      allocate(size_t __n)
      {
        if (std::__is_constant_evaluated())
          {
            if (__builtin_mul_overflow(__n, sizeof(_Tp), &__n))
              std::__throw_bad_array_new_length();
            return static_cast<_Tp*>(::operator new(__n));
          }

        return __allocator_base<_Tp>::allocate(__n, 0);
      }

```

We could call ~_Tp() for each trivially destructible types, but this will not
help with implicit lifetime aggregates with non-trivial destructor (we cannot
call it).

Reply via email to