[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
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=219785root=gccview=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
[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
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
[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
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
[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
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=32994action=edit stop the inheritance recursion at the last element This fixes all the issues mentioned here
[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
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!
[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
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::tuplestd::tuplestd::tuplestd::tuple grow linearly with the nesting depth. That's PR51653. With the attached patch that occupies a single byte, for any depth.
[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
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.
[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
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?
[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
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::tupleEmpty { double d; };
[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
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. :)
[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
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56785 --- Comment #5 from Jonathan Wakely redi at gcc dot gnu.org --- The solution I'm testing is to give every tuple hierarchy a distinct base class, differentiated by an unused template argument that depends on the types of all the elements, so the base classes can be at the same address. The downside is this produces additional instantiations for programs using different tuple types that have common tails, e.g. tupleA,B,C and tupleD,B,C would no longer share any code. Those class instantiation shouldn't generate much code, so maybe that's not an issue
[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
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.
[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
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(pairpairchar,char,pairchar,char) == 4 while sizeof(tupletuplechar,char,tuplechar,char) == 5 (!!). I think that at the moment, GCC users are best advised to avoid using stdlib tuples if efficiency is a concern.
[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
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(pairpairchar,char,pairchar,char) == 4 while sizeof(tupletuplechar,char,tuplechar,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.
[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
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_implN 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.
[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
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
[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
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::tuplestd::tuplestd::tuplestd::tuple grow linearly with the nesting depth.