LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 41714 - std::tuple<> is not trivially constructible
Summary: std::tuple<> is not trivially constructible
Status: RESOLVED FIXED
Alias: None
Product: libc++
Classification: Unclassified
Component: All Bugs (show other bugs)
Version: unspecified
Hardware: PC Linux
: P enhancement
Assignee: Louis Dionne
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-02 11:02 PDT by Rafael Ávila de Espíndola
Modified: 2019-06-11 08:06 PDT (History)
4 users (show)

See Also:
Fixed By Commit(s): r363075


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Ávila de Espíndola 2019-05-02 11:02:47 PDT
Clang -std=c++17 compiles the following if using libstdc++:

#include <tuple>
static_assert(std::is_trivially_constructible_v<std::tuple<>>);

But adding -stdlib=libc++ causes

test.cc:3:1: error: static_assert failed due to requirement 'std::is_trivially_constructible_v<std::__1::tuple<>>
Comment 1 Marshall Clow (home) 2019-05-02 16:04:03 PDT
A few minutes of looking through the standard did not turn up any requirement that tuple<> be trivially constructible.

trivially *destructible*, yes.
> 4 If is_trivially_destructible_v<Ti> is true for all Ti, then the destructor of tuple is trivial.

constexpr, yes.
> The defaulted move and copy constructor of tuple<> shall be constexpr functions.

Can you tell me where you believe this requirement comes from?
Comment 2 Rafael Ávila de Espíndola 2019-05-03 08:15:48 PDT
I have no idea if the standard requires this, but it would be a nice to have extension if it doesn't. Specially considering that libstdc++ has it.
Comment 3 Marshall Clow (home) 2019-05-03 09:34:36 PDT
(In reply to Rafael Ávila de Espíndola from comment #2)
> I have no idea if the standard requires this, but it would be a nice to have
> extension if it doesn't. Specially considering that libstdc++ has it.

Generally speaking, I'm philosophically opposed to "things that everyone does, but aren't in the standard".

If this is a good thing, then we should write it into the standard.
Comment 4 Louis Dionne 2019-05-29 12:16:06 PDT
I think it's a reasonable thing to do as a matter of QOI. The change is very simple, too, and it's the natural way to write that default constructor IMO.

Review here: https://reviews.llvm.org/D62618
Comment 5 Louis Dionne 2019-06-11 08:06:36 PDT
Fixed in r363075.