public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/94831] New: [10 Regression] vector<float[2]> no longer compiles
@ 2020-04-28 19:45 redi at gcc dot gnu.org
  2020-04-28 19:46 ` [Bug libstdc++/94831] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2020-04-28 19:45 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-04-28 22:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-28 19:45 [Bug libstdc++/94831] New: [10 Regression] vector<float[2]> no longer compiles redi at gcc dot gnu.org
2020-04-28 19:46 ` [Bug libstdc++/94831] " redi at gcc dot gnu.org
2020-04-28 20:01 ` redi at gcc dot gnu.org
2020-04-28 21:39 ` redi at gcc dot gnu.org
2020-04-28 22:48 ` cvs-commit at gcc dot gnu.org
2020-04-28 22:54 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).