[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

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jun 16 22:10:00 GMT 2014


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.



More information about the Gcc-bugs mailing list