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

            Bug ID: 94831
           Summary: [10 Regression] vector<float[2]> no longer compiles
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

In r277342 I changed std::_Construct for P0784R7, "More constexpr containers"
and the non-void return type means this no longer compiles:

#include <vector>
std::vector<float[2]> v(1);

This was never valid in C++98, and in C++11 to C++17 it's undefined (because
the pseudo-destructor call in allocator_traits<std::allocator<T>>::destroy is
ill-formed for arrays). But for libstdc++ it happened to compile, because we
elide the calls to trivial destructors.

Since r277342 we impement std::construct_at semantics in std::_Construct which
means it returns non-void, but the result of the new-expression for an array
type is not convertible to a pointer to the array:

/home/jwakely/src/gcc/gcc/libstdc++-v3/include/bits/stl_construct.h:111:31:
error: cannot convert 'float*' to 'float (*)[2]' in return
  111 |       return std::construct_at(__p, std::forward<_Args>(__args)...);
      |              ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                               |
      |                               float*

This is arguably OK for C++20 where the specification of std::construct_at is
clear, but it's a regression for C++11/14/17.

I propose to restore support for vector<float[2]> for c++11/14/17 and gnu++20,
so we can at least introduce a period of deprecation before removing the
support completely.

Reply via email to