C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Proposed defect report related to std::array<T, 0>

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Fri, 15 Dec 2023 23:37:39 +0000
On Fri, 15 Dec 2023 at 21:56, Ryan Nicholl via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> I would like to semi-formally propose a defect report related to
> std::array and existing standards.
>
> It turns out std::array<T, 0> cannot be implemented in C++17 without the
> use of magic compiler builtins. libc++, libstdc++, and I think also MSVC
> are all non-compliant.
>
> Begin and end are required to return a unique pointer, the only constexpr
> method I have found to do this is taking the address of a union member.
> However, that approach breaks if T is non-trivial.
>

This is https://cplusplus.github.io/LWG/issue2157


> Glibc libstdc++ libc++ ignores the standard requirement of uniqueness in
> favor of following the trivial and constexpr requirements. Both of these
> implementations return nullptr.
>

N.B. There's no such thing as Glibc libstdc++. Libstdc++ is part of GCC,
which is a completely separate project from Glibc.

Received on 2023-12-15 23:37:54