public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51453] New: Feature request: Implement Empty Base Optimization in std::tuple
@ 2011-12-07 17:50 nasos_i at hotmail dot com
  2011-12-07 18:01 ` [Bug libstdc++/51453] " paolo.carlini at oracle dot com
  2011-12-07 18:08 ` redi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: nasos_i at hotmail dot com @ 2011-12-07 17:50 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51453

             Bug #: 51453
           Summary: Feature request: Implement Empty Base Optimization in
                    std::tuple
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: nasos_i@hotmail.com


Is it possible to implement empty base optimization on std::tuple, so that
tuples with member free elements have no memory footprint?


struct _Tuple_impl<_Idx>
    { 
    ...
    protected:
      short dummy[0]; // NEW
      void _M_swap_impl(_Tuple_impl&) { /* no-op */ }
    };


simple test:

#include <tuple>
...
    class empty { short d[0]; };
    std::tuple<empty, empty, empty> a;
    std::cout << sizeof(a) << std::endl; // 2 without tuple ebo (current), and
0 with tuple ebo
...

Best,
Nasos


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libstdc++/51453] Feature request: Implement Empty Base Optimization in std::tuple
  2011-12-07 17:50 [Bug c++/51453] New: Feature request: Implement Empty Base Optimization in std::tuple nasos_i at hotmail dot com
@ 2011-12-07 18:01 ` paolo.carlini at oracle dot com
  2011-12-07 18:08 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-12-07 18:01 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51453

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |libstdc++

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-12-07 18:01:22 UTC ---
I don't think we should fiddle with illegal zero lenght arrays in the C++11
library, even if in general it's a GNU E extension. Of course we are already
exploiting EBO for portable data types.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libstdc++/51453] Feature request: Implement Empty Base Optimization in std::tuple
  2011-12-07 17:50 [Bug c++/51453] New: Feature request: Implement Empty Base Optimization in std::tuple nasos_i at hotmail dot com
  2011-12-07 18:01 ` [Bug libstdc++/51453] " paolo.carlini at oracle dot com
@ 2011-12-07 18:08 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2011-12-07 18:08 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51453

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |WORKSFORME

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-12-07 18:08:06 UTC ---
(In reply to comment #0)
> // 2 without tuple ebo (current), and 0 with tuple ebo

A complete object cannot have zero size.

std::tuple is exploiting the EBO *more* than it should (see PR 51365) but as
long as you don't use 'final' it will already do what you want


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-12-07 18:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-07 17:50 [Bug c++/51453] New: Feature request: Implement Empty Base Optimization in std::tuple nasos_i at hotmail dot com
2011-12-07 18:01 ` [Bug libstdc++/51453] " paolo.carlini at oracle dot com
2011-12-07 18:08 ` redi at gcc dot gnu.org

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).