public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [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
@ 2013-03-30  2:58 david at doublewise dot net
  2013-03-30  9:06 ` [Bug libstdc++/56785] " glisse at gcc dot gnu.org
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: david at doublewise dot net @ 2013-03-30  2:58 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56785
           Summary: std::tuple of two elements does not apply empty base
                    class optimization when one of its elements is a
                    std::tuple with two elements
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: david@doublewise.net


#include <tuple>

class Empty {
};

int main() {
    static_assert(sizeof(std::tuple<Empty, std::tuple<int, int>>) ==
sizeof(std::tuple<int, int>), "Too big");
}

[david@localhost test]$ g++ source/test.cpp -std=c++11 -Wall -Wextra -pedantic
source/test.cpp: In function ‘int main()’:
source/test.cpp:23:2: error: static assertion failed: Too big


The static_assert does not fail if I change it to be a std::tuple<int, int,
int> on both sides, however, or any number of int other than exactly 2. I also
get this bug regardless of the type in the std::tuple (for instance, my own
class type).

Therefore, I have created a workaround, demonstrated such:

#include <tuple>

class Empty {
};
class Empty2 {
};

int main() {
    static_assert(sizeof(std::tuple<Empty, std::tuple<int, short>, Empty2>) ==
sizeof(std::tuple<int, short, Empty2>), "Too big");
    static_assert(sizeof(std::tuple<Empty, std::tuple<int, int>, Empty2>) ==
sizeof(int) * 2, "Too big");
}






[david@localhost test]$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.7.2/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-bootstrap --enable-shared --enable-threads=posix
--enable-checking=release --disable-build-with-cxx
--disable-build-poststage1-with-cxx --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-gnu-unique-object
--enable-linker-build-id --with-linker-hash-style=gnu
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin
--enable-initfini-array --enable-java-awt=gtk --disable-dssi
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib
--with-ppl --with-cloog --with-tune=generic --with-arch_32=i686
--build=x86_64-redhat-linux
Thread model: posix
gcc version 4.7.2 20121109 (Red Hat 4.7.2-8) (GCC)
>From gcc-bugs-return-418792-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Mar 30 02:58:38 2013
Return-Path: <gcc-bugs-return-418792-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 12416 invoked by alias); 30 Mar 2013 02:58:38 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 12373 invoked by uid 48); 30 Mar 2013 02:58:30 -0000
From: "jvdelisle at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libfortran/49791] [4.6/4.7/4.8/4.9 Regression] Formatted namelist reads fails with: Cannot match namelist object
Date: Sat, 30 Mar 2013 02:58:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: libfortran
X-Bugzilla-Keywords: wrong-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jvdelisle at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P4
X-Bugzilla-Assigned-To: jvdelisle at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.6.4
X-Bugzilla-Changed-Fields:
Message-ID: <bug-49791-4-a6bNkNeaxz@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-49791-4@http.gcc.gnu.org/bugzilla/>
References: <bug-49791-4@http.gcc.gnu.org/bugzilla/>
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
Content-Type: text/plain; charset="UTF-8"
MIME-Version: 1.0
X-SW-Source: 2013-03/txt/msg02233.txt.bz2
Content-length: 360


http://gcc.gnu.org/bugzilla/show_bug.cgi?idI791

--- Comment #24 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> 2013-03-30 02:58:25 UTC ---
Created attachment 29751
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id)751
Related test case

This example fails with a runtime error and passes with ifort.  The other cases
in this PR are fixed.


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

end of thread, other threads:[~2015-01-17  0:24 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
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
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
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

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