C++ Logo

std-proposals

Advanced search

Re: [std-proposals] 回复: Potential defect in std::construct_at

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Sun, 8 Dec 2024 13:41:00 +0000
On Sun, 8 Dec 2024, 12:51 Marcin Jaczewski via Std-Proposals, <
std-proposals_at_[hidden]> wrote:

> niedz., 8 gru 2024 o 12:04 F. v.S. via Std-Proposals
> <std-proposals_at_[hidden]> napisał(a):
> >
> > Hi!
> >
> > This is a known LWG issue which has been resolved:
> https://cplusplus.github.io/LWG/issue3870.
> >
> > If you use the latest libc++ (Clang 20 trunk), the latest libstdc++ (GCC
> 15 trunk), or MSVC STL since VS 2022 17.7, the casting-away-constness use
> of construct_at will be error.
> >
> > Thanks,
> > F.v.S.
> >
>
> And `a.~T()` is still legal? Should here const cast be required too?
>

No, you can always destroy const objects, otherwise you couldn't define {
const T a; } because the implicit destruction would not be allowed.

You can also use a const T* as the operand of a delete expression.

Received on 2024-12-08 13:42:21