* [Bug libstdc++/56785] std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements
2013-03-30 2:58 [Bug libstdc++/56785] New: std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements david at doublewise dot net
@ 2013-03-30 9:06 ` glisse at gcc dot gnu.org
2013-04-08 8:47 ` redi at gcc dot gnu.org
` (14 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: glisse at gcc dot gnu.org @ 2013-03-30 9:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56785
--- Comment #1 from Marc Glisse <glisse at gcc dot gnu.org> 2013-03-30 09:06:44 UTC ---
I assume (needs to be checked) this is related to the issue, reported
elsewhere, that makes the size of
std::tuple<std::tuple<std::tuple<std::tuple<>>>> grow linearly with the nesting
depth.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/56785] std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements
2013-03-30 2:58 [Bug libstdc++/56785] New: std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements david at doublewise dot net
2013-03-30 9:06 ` [Bug libstdc++/56785] " glisse at gcc dot gnu.org
@ 2013-04-08 8:47 ` redi at gcc dot gnu.org
2014-06-16 19:01 ` gcc-bugzilla at contacts dot eelis.net
` (13 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: redi at gcc dot gnu.org @ 2013-04-08 8:47 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56785
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/56785] std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements
2013-03-30 2:58 [Bug libstdc++/56785] New: std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements david at doublewise dot net
2013-03-30 9:06 ` [Bug libstdc++/56785] " glisse at gcc dot gnu.org
2013-04-08 8:47 ` redi at gcc dot gnu.org
@ 2014-06-16 19:01 ` gcc-bugzilla at contacts dot eelis.net
2014-06-16 22:10 ` redi at gcc dot gnu.org
` (12 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: gcc-bugzilla at contacts dot eelis.net @ 2014-06-16 19:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56785
Eelis <gcc-bugzilla at contacts dot eelis.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gcc-bugzilla at contacts dot eelis
| |.net
--- Comment #2 from Eelis <gcc-bugzilla at contacts dot eelis.net> ---
Another manifestation of this is that
sizeof(pair<pair<char,char>,pair<char,char>>) == 4
while
sizeof(tuple<tuple<char,char>,tuple<char,char>>) == 5 (!!).
I think that at the moment, GCC users are best advised to avoid using stdlib
tuples if efficiency is a concern.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/56785] std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements
2013-03-30 2:58 [Bug libstdc++/56785] New: std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements david at doublewise dot net
` (2 preceding siblings ...)
2014-06-16 19:01 ` gcc-bugzilla at contacts dot eelis.net
@ 2014-06-16 22:10 ` redi at gcc dot gnu.org
2014-06-16 22:28 ` redi at gcc dot gnu.org
` (11 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: redi at gcc dot gnu.org @ 2014-06-16 22:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56785
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Eelis from comment #2)
> Another manifestation of this is that
>
> sizeof(pair<pair<char,char>,pair<char,char>>) == 4
>
> while
>
> sizeof(tuple<tuple<char,char>,tuple<char,char>>) == 5 (!!).
Oh noes, one byte more for a silly edge case!
> I think that at the moment, GCC users are best advised to avoid using stdlib
> tuples if efficiency is a concern.
That's a ridiculous conclusion to reach based on an edge case.
There are many realistic situations where std::tuple is more compact that
std::pair.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/56785] std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements
2013-03-30 2:58 [Bug libstdc++/56785] New: std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements david at doublewise dot net
` (3 preceding siblings ...)
2014-06-16 22:10 ` redi at gcc dot gnu.org
@ 2014-06-16 22:28 ` redi at gcc dot gnu.org
2014-06-17 17:02 ` gcc-bugzilla at contacts dot eelis.net
` (10 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: redi at gcc dot gnu.org @ 2014-06-16 22:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56785
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The cause is that every N-tuple hierarchy ends with an empty _Tuple_impl<N>
base, so when there are several of those in the same hierarchy they need to
have separate addresses.
It should be possible to fix by eliminating that terminal objet in the
inheritance hierarchy. The obvious way duplicates a chunk of code, I think it
should be possible to do it in a nicer way, which I'm experimenting with.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/56785] std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements
2013-03-30 2:58 [Bug libstdc++/56785] New: std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements david at doublewise dot net
` (4 preceding siblings ...)
2014-06-16 22:28 ` redi at gcc dot gnu.org
@ 2014-06-17 17:02 ` gcc-bugzilla at contacts dot eelis.net
2014-06-18 13:43 ` redi at gcc dot gnu.org
` (9 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: gcc-bugzilla at contacts dot eelis.net @ 2014-06-17 17:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56785
--- Comment #6 from Eelis <gcc-bugzilla at contacts dot eelis.net> ---
Clang's libc++ (which gives the expected result) might be another source of
inspiration.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/56785] std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements
2013-03-30 2:58 [Bug libstdc++/56785] New: std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements david at doublewise dot net
` (5 preceding siblings ...)
2014-06-17 17:02 ` gcc-bugzilla at contacts dot eelis.net
@ 2014-06-18 13:43 ` redi at gcc dot gnu.org
2014-06-18 14:25 ` gcc-bugzilla at contacts dot eelis.net
` (8 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: redi at gcc dot gnu.org @ 2014-06-18 13:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56785
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
IIRC with libc++ tuple<> is not an empty type, so has more overhead than ours
in other edge cases. Maybe you should recommend users stay away from that too.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/56785] std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements
2013-03-30 2:58 [Bug libstdc++/56785] New: std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements david at doublewise dot net
` (6 preceding siblings ...)
2014-06-18 13:43 ` redi at gcc dot gnu.org
@ 2014-06-18 14:25 ` gcc-bugzilla at contacts dot eelis.net
2014-06-18 14:39 ` glisse at gcc dot gnu.org
` (7 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: gcc-bugzilla at contacts dot eelis.net @ 2014-06-18 14:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56785
--- Comment #8 from Eelis <gcc-bugzilla at contacts dot eelis.net> ---
With Clang 3.5, given
struct X: std::tuple<> { char c; };
I get sizeof(X)==1. Is that not what you mean?
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/56785] std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements
2013-03-30 2:58 [Bug libstdc++/56785] New: std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements david at doublewise dot net
` (7 preceding siblings ...)
2014-06-18 14:25 ` gcc-bugzilla at contacts dot eelis.net
@ 2014-06-18 14:39 ` glisse at gcc dot gnu.org
2014-06-18 14:47 ` gcc-bugzilla at contacts dot eelis.net
` (6 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: glisse at gcc dot gnu.org @ 2014-06-18 14:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56785
--- Comment #9 from Marc Glisse <glisse at gcc dot gnu.org> ---
Try:
struct X: std::tuple<Empty> { double d; };
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/56785] std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements
2013-03-30 2:58 [Bug libstdc++/56785] New: std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements david at doublewise dot net
` (8 preceding siblings ...)
2014-06-18 14:39 ` glisse at gcc dot gnu.org
@ 2014-06-18 14:47 ` gcc-bugzilla at contacts dot eelis.net
2014-06-23 23:13 ` redi at gcc dot gnu.org
` (5 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: gcc-bugzilla at contacts dot eelis.net @ 2014-06-18 14:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56785
--- Comment #10 from Eelis <gcc-bugzilla at contacts dot eelis.net> ---
I see what you mean! And while stuff with empty types and EBO is IMHO not
nearly as serious as random superfluous bytes that are inserted when you use
tuples of a bread and butter type like char, I agree it would be good to file a
ticket in http://llvm.org/bugs/ if there isn't one already. :)
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/56785] std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements
2013-03-30 2:58 [Bug libstdc++/56785] New: std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements david at doublewise dot net
` (9 preceding siblings ...)
2014-06-18 14:47 ` gcc-bugzilla at contacts dot eelis.net
@ 2014-06-23 23:13 ` redi at gcc dot gnu.org
2014-06-23 23:21 ` gcc-bugzilla at contacts dot eelis.net
` (4 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: redi at gcc dot gnu.org @ 2014-06-23 23:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56785
--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Created attachment 32994
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=32994&action=edit
stop the inheritance recursion at the last element
This fixes all the issues mentioned here
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/56785] std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements
2013-03-30 2:58 [Bug libstdc++/56785] New: std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements david at doublewise dot net
` (10 preceding siblings ...)
2014-06-23 23:13 ` redi at gcc dot gnu.org
@ 2014-06-23 23:21 ` gcc-bugzilla at contacts dot eelis.net
2014-06-23 23:21 ` redi at gcc dot gnu.org
` (3 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: gcc-bugzilla at contacts dot eelis.net @ 2014-06-23 23:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56785
--- Comment #12 from Eelis <gcc-bugzilla at contacts dot eelis.net> ---
Ooh, very nice! Thanks!
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/56785] std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements
2013-03-30 2:58 [Bug libstdc++/56785] New: std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements david at doublewise dot net
` (11 preceding siblings ...)
2014-06-23 23:21 ` gcc-bugzilla at contacts dot eelis.net
@ 2014-06-23 23:21 ` redi at gcc dot gnu.org
2014-09-19 11:01 ` redi at gcc dot gnu.org
` (2 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: redi at gcc dot gnu.org @ 2014-06-23 23:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56785
--- Comment #13 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Marc Glisse from comment #1)
> I assume (needs to be checked) this is related to the issue, reported
> elsewhere, that makes the size of
> std::tuple<std::tuple<std::tuple<std::tuple<>>>> grow linearly with the
> nesting depth.
That's PR51653. With the attached patch that occupies a single byte, for any
depth.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/56785] std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements
2013-03-30 2:58 [Bug libstdc++/56785] New: std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements david at doublewise dot net
` (12 preceding siblings ...)
2014-06-23 23:21 ` redi at gcc dot gnu.org
@ 2014-09-19 11:01 ` redi at gcc dot gnu.org
2015-01-17 0:22 ` redi at gcc dot gnu.org
2015-01-17 0:24 ` redi at gcc dot gnu.org
15 siblings, 0 replies; 17+ messages in thread
From: redi at gcc dot gnu.org @ 2014-09-19 11:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56785
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2014-09-19
Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org
Target Milestone|--- |5.0
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/56785] std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements
2013-03-30 2:58 [Bug libstdc++/56785] New: std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements david at doublewise dot net
` (13 preceding siblings ...)
2014-09-19 11:01 ` redi at gcc dot gnu.org
@ 2015-01-17 0:22 ` redi at gcc dot gnu.org
2015-01-17 0:24 ` redi at gcc dot gnu.org
15 siblings, 0 replies; 17+ messages in thread
From: redi at gcc dot gnu.org @ 2015-01-17 0:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56785
--- Comment #14 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Sat Jan 17 00:21:41 2015
New Revision: 219785
URL: https://gcc.gnu.org/viewcvs?rev=219785&root=gcc&view=rev
Log:
PR libstdc++/56785
* include/std/tuple (_Tuple_impl): Remove zero-element specialization
and define one-element specialization.
* testsuite/20_util/tuple/56785.cc: New.
Added:
trunk/libstdc++-v3/testsuite/20_util/tuple/56785.cc
Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/include/std/tuple
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug libstdc++/56785] std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements
2013-03-30 2:58 [Bug libstdc++/56785] New: std::tuple of two elements does not apply empty base class optimization when one of its elements is a std::tuple with two elements david at doublewise dot net
` (14 preceding siblings ...)
2015-01-17 0:22 ` redi at gcc dot gnu.org
@ 2015-01-17 0:24 ` redi at gcc dot gnu.org
15 siblings, 0 replies; 17+ messages in thread
From: redi at gcc dot gnu.org @ 2015-01-17 0:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56785
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #15 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for GCC 5
^ permalink raw reply [flat|nested] 17+ messages in thread