public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/116440] New: [C++20] std::tuple<std::tuple<std::any>> does not compile
@ 2024-08-21 11:29 tianchengyu at tencent dot com
2024-08-21 11:37 ` [Bug c++/116440] " tianchengyu at tencent dot com
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: tianchengyu at tencent dot com @ 2024-08-21 11:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116440
Bug ID: 116440
Summary: [C++20] std::tuple<std::tuple<std::any>> does not
compile
Product: gcc
Version: 14.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: tianchengyu at tencent dot com
Target Milestone: ---
The following code (minimized reproduction) does not compile since gcc 14
(tested on 14.1.0 and 14.2.0), also failed on trunk (as of 20240821).
template <typename T>
using TupleTuple = std::tuple<std::tuple<T>>; // can be replaced with
std::tuple<std::tuple<...>> in following code, just to make it shorter.
struct EmbedAny {
std::any content;
};
// Does not compile: struct with only one std::any field
static_assert(std::is_copy_constructible<TupleTuple<EmbedAny>>::value);
// Does not compile: just std::any in nested std::tuple
static_assert(std::is_copy_constructible<TupleTuple<std::any>>::value);
However, if we add anything before the std::any field, it compiles fine (even a
zero-sized array!):
struct EmbedAnyWithZeroSizeArray {
void* pad[0]; // or, e.g. int pad; would also compile
std::any content;
};
// Compiles: add a zero-sized (or any size) field **before** std::any field.
Adding the field after std::any does not work.
static_assert(std::is_copy_constructible<TupleTuple<EmbedAnyWithZeroSizeArray>>::value);
This only fails on gcc 14+ with -std=c++20 or higher. On older gcc versions
with -std=c++20 or gcc 14+ with -std=c++17 it compiles fine.
I also observed that clang trunk failed to compile with similar errors, but
clang 18 works fine, too.
Godbolt sample: https://godbolt.org/z/Gds4ar716
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/116440] [C++20] std::tuple<std::tuple<std::any>> does not compile
2024-08-21 11:29 [Bug c++/116440] New: [C++20] std::tuple<std::tuple<std::any>> does not compile tianchengyu at tencent dot com
@ 2024-08-21 11:37 ` tianchengyu at tencent dot com
2024-08-21 12:08 ` [Bug c++/116440] [14/15 Regression] " redi at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: tianchengyu at tencent dot com @ 2024-08-21 11:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116440
--- Comment #1 from tianchengyu(余添诚) <tianchengyu at tencent dot com> ---
Note that in the sample I used static_assert(std::is_copy_constructible<...>)
for testing, but it is not that is_copy_constructible is false. The
std::tuple<std::tuple<std::any>>> type simply does not compile at all.
Unsure if this is a c++ frontend issue or a libstdc++ issue.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/116440] [14/15 Regression] [C++20] std::tuple<std::tuple<std::any>> does not compile
2024-08-21 11:29 [Bug c++/116440] New: [C++20] std::tuple<std::tuple<std::any>> does not compile tianchengyu at tencent dot com
2024-08-21 11:37 ` [Bug c++/116440] " tianchengyu at tencent dot com
@ 2024-08-21 12:08 ` redi at gcc dot gnu.org
2024-08-22 2:16 ` tianchengyu at tencent dot com
2024-08-22 2:30 ` tianchengyu at tencent dot com
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2024-08-21 12:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116440
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Tiancheng Yu from comment #0)
> This only fails on gcc 14+ with -std=c++20 or higher. On older gcc versions
> with -std=c++20 or gcc 14+ with -std=c++17 it compiles fine.
GCC 14 has new definitions of std::tuple constructors that are used when C++20
is enabled, controlled by:
#if __cpp_concepts && __cpp_consteval && __cpp_conditional_explicit
> I also observed that clang trunk failed to compile with similar errors,
Because it's using the new libstdc++ headers.
> but
> clang 18 works fine, too.
Almost certainly because it's using older libstdc++ headers, probably from GCC
13.
It's not very useful to just say something works with clang on godbolt without
considering
whether it's using libc++ or libstdc++, and for the latter, *which version* of
libstdc++.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/116440] [14/15 Regression] [C++20] std::tuple<std::tuple<std::any>> does not compile
2024-08-21 11:29 [Bug c++/116440] New: [C++20] std::tuple<std::tuple<std::any>> does not compile tianchengyu at tencent dot com
2024-08-21 11:37 ` [Bug c++/116440] " tianchengyu at tencent dot com
2024-08-21 12:08 ` [Bug c++/116440] [14/15 Regression] " redi at gcc dot gnu.org
@ 2024-08-22 2:16 ` tianchengyu at tencent dot com
2024-08-22 2:30 ` tianchengyu at tencent dot com
3 siblings, 0 replies; 5+ messages in thread
From: tianchengyu at tencent dot com @ 2024-08-22 2:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116440
--- Comment #3 from Tiancheng Yu <tianchengyu at tencent dot com> ---
(In reply to Jonathan Wakely from comment #2)
> It's not very useful to just say something works with clang on godbolt
> without considering
> whether it's using libc++ or libstdc++, and for the latter, *which version*
> of libstdc++.
Sorry for not being clear. clang does not compile with libstdc++ (trunk, as of
20240821), but works fine with libc++.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/116440] [14/15 Regression] [C++20] std::tuple<std::tuple<std::any>> does not compile
2024-08-21 11:29 [Bug c++/116440] New: [C++20] std::tuple<std::tuple<std::any>> does not compile tianchengyu at tencent dot com
` (2 preceding siblings ...)
2024-08-22 2:16 ` tianchengyu at tencent dot com
@ 2024-08-22 2:30 ` tianchengyu at tencent dot com
3 siblings, 0 replies; 5+ messages in thread
From: tianchengyu at tencent dot com @ 2024-08-22 2:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116440
--- Comment #4 from Tiancheng Yu <tianchengyu at tencent dot com> ---
on clang 18.1, works with both libstdc++ (from GCC 13.2.0) and libc++.
on clang trunk, works with libc++ (trunk) but not libstdc++ (trunk).
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-08-22 2:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-21 11:29 [Bug c++/116440] New: [C++20] std::tuple<std::tuple<std::any>> does not compile tianchengyu at tencent dot com
2024-08-21 11:37 ` [Bug c++/116440] " tianchengyu at tencent dot com
2024-08-21 12:08 ` [Bug c++/116440] [14/15 Regression] " redi at gcc dot gnu.org
2024-08-22 2:16 ` tianchengyu at tencent dot com
2024-08-22 2:30 ` tianchengyu at tencent dot com
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).