public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17287] New: Different class layout generated by g++ 3.3, 3.4 and 3.5.
@ 2004-09-02 13:53 yanliu at ca dot ibm dot com
2004-09-02 13:59 ` [Bug c++/17287] " yanliu at ca dot ibm dot com
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: yanliu at ca dot ibm dot com @ 2004-09-02 13:53 UTC (permalink / raw)
To: gcc-bugs
I found that g++ 3.3, 3.4 and 3.5 generate different class layouts for the
following testcase:
struct A {char a;};
struct B: virtual public A {};
struct C:public B{
int c;
virtual void f() {};
};
struct D {
char d;
};
struct E {int:3;};
struct F: public C, virtual E, public D {
char f1;
virtual void f(){}
};
int main()
{F f;}
g++ 3.3's information is:
Configured with: ../configure --enable-threads=posix --prefix=/usr
--with-local-prefix=/usr/local --infodir=/usr/share/info
--mandir=/usr/share/man --enable-languages=c,c++,f77,objc,java,ada
--disable-checking --libdir=/usr/lib --enable-libgcj
--with-gxx-include-dir=/usr/include/g++ --with-slibdir=/lib
--with-system-zlib --enable-shared --enable-__cxa_atexit
--host=powerpc-suse-linux --build=powerpc-suse-linux
--target=powerpc-suse-linux --enable-targets=powerpc64-suse-linux
--enable-biarch
Thread model: posix
gcc version 3.3.3 (SuSE Linux)
g++3.4's information is:
Configured with: ../gcc/configure
--prefix=/.../torolab.ibm.com/fs/projects/vabld/run/gcc/linux_ppc/3.4-dev
--enable-languages=c,c++,f77,objc --enable-altivec --enable-shared
powerpc-suse-linux
Thread model: posix
gcc version 3.4.0 20040212 (prerelease)
g++ 3.5's information is:
Configured with: /private/var/tmp/gcc/gcc-1765.obj~1/src/configure
--disable-checking --prefix=/usr --disable-libmudflap --mandir=/share/man
--enable-languages=c,objc,c++ --disable-libada
--program-transform-name=/^[cg][^+.-]*$/s/$/-3.5/
--with-gxx-include-dir=/include/gcc/darwin/3.5/c++
--build=powerpc-apple-darwin --host=powerpc-apple-darwin
--target=powerpc-apple-darwin
Thread model: posix
gcc version 3.5.0-tree-ssa 20040321 (merged 20040529) (Apple Computer, Inc.
build 1765)
Three attached files contain the class layout results with three g++
compilers using -fdump-class-hierarchy options.
I noticed that from g++3.3 to g++3.4, you changed the rule of the starting
offset of virtual bases. The virtual bases can be put at offset which is not
the multiple of the current class's alignment. In this testcase, after mapping
the virtual base class A while mapping of the most derived class F, the
dsize(F)=11, size(F)=11, align(F)=4, and nvsize(E)=4, nvalign(E)=4. So, when
mapping virtual base class E, the next available bits are at offset dsize(F)=11.
E should be put at offset(F) which is the dsize(F) =11, and the final class
size should be 12. To me, g++3.4 gives the most reasonable result, I don't
understand why g++3.5 put E at offset 12, and the final class size is 16.
Can you explain the class mapping rule in more detail?
--
Summary: Different class layout generated by g++ 3.3, 3.4 and
3.5.
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: yanliu at ca dot ibm dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17287
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/17287] Different class layout generated by g++ 3.3, 3.4 and 3.5.
2004-09-02 13:53 [Bug c++/17287] New: Different class layout generated by g++ 3.3, 3.4 and 3.5 yanliu at ca dot ibm dot com
@ 2004-09-02 13:59 ` yanliu at ca dot ibm dot com
2004-09-02 14:00 ` yanliu at ca dot ibm dot com
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: yanliu at ca dot ibm dot com @ 2004-09-02 13:59 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From yanliu at ca dot ibm dot com 2004-09-02 13:59 -------
Created an attachment (id=7028)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=7028&action=view)
class layout generated by g++3.3 compiler
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17287
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/17287] Different class layout generated by g++ 3.3, 3.4 and 3.5.
2004-09-02 13:53 [Bug c++/17287] New: Different class layout generated by g++ 3.3, 3.4 and 3.5 yanliu at ca dot ibm dot com
2004-09-02 13:59 ` [Bug c++/17287] " yanliu at ca dot ibm dot com
@ 2004-09-02 14:00 ` yanliu at ca dot ibm dot com
2004-09-02 14:00 ` yanliu at ca dot ibm dot com
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: yanliu at ca dot ibm dot com @ 2004-09-02 14:00 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From yanliu at ca dot ibm dot com 2004-09-02 14:00 -------
Created an attachment (id=7029)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=7029&action=view)
class layout generated by g++ 3.4 32 bit mode
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17287
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/17287] Different class layout generated by g++ 3.3, 3.4 and 3.5.
2004-09-02 13:53 [Bug c++/17287] New: Different class layout generated by g++ 3.3, 3.4 and 3.5 yanliu at ca dot ibm dot com
2004-09-02 13:59 ` [Bug c++/17287] " yanliu at ca dot ibm dot com
2004-09-02 14:00 ` yanliu at ca dot ibm dot com
@ 2004-09-02 14:00 ` yanliu at ca dot ibm dot com
2004-09-03 17:14 ` giovannibajo at libero dot it
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: yanliu at ca dot ibm dot com @ 2004-09-02 14:00 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From yanliu at ca dot ibm dot com 2004-09-02 14:00 -------
Created an attachment (id=7030)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=7030&action=view)
class layout generated by g++ 3.5 compiler
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17287
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/17287] Different class layout generated by g++ 3.3, 3.4 and 3.5.
2004-09-02 13:53 [Bug c++/17287] New: Different class layout generated by g++ 3.3, 3.4 and 3.5 yanliu at ca dot ibm dot com
` (2 preceding siblings ...)
2004-09-02 14:00 ` yanliu at ca dot ibm dot com
@ 2004-09-03 17:14 ` giovannibajo at libero dot it
2004-09-03 17:18 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: giovannibajo at libero dot it @ 2004-09-03 17:14 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ABI, wrong-code
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17287
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/17287] Different class layout generated by g++ 3.3, 3.4 and 3.5.
2004-09-02 13:53 [Bug c++/17287] New: Different class layout generated by g++ 3.3, 3.4 and 3.5 yanliu at ca dot ibm dot com
` (3 preceding siblings ...)
2004-09-03 17:14 ` giovannibajo at libero dot it
@ 2004-09-03 17:18 ` pinskia at gcc dot gnu dot org
2004-10-03 19:10 ` [Bug c++/17287] Different class layout generated by g++ 3.3, 3.4 and 4.0 pinskia at gcc dot gnu dot org
2004-10-12 5:54 ` mmitchel at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-03 17:18 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |critical
Target Milestone|--- |3.4.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17287
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/17287] Different class layout generated by g++ 3.3, 3.4 and 4.0.
2004-09-02 13:53 [Bug c++/17287] New: Different class layout generated by g++ 3.3, 3.4 and 3.5 yanliu at ca dot ibm dot com
` (4 preceding siblings ...)
2004-09-03 17:18 ` pinskia at gcc dot gnu dot org
@ 2004-10-03 19:10 ` pinskia at gcc dot gnu dot org
2004-10-12 5:54 ` mmitchel at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-03 19:10 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Summary|Different class layout |Different class layout
|generated by g++ 3.3, 3.4 |generated by g++ 3.3, 3.4
|and 3.5. |and 4.0.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17287
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/17287] Different class layout generated by g++ 3.3, 3.4 and 4.0.
2004-09-02 13:53 [Bug c++/17287] New: Different class layout generated by g++ 3.3, 3.4 and 3.5 yanliu at ca dot ibm dot com
` (5 preceding siblings ...)
2004-10-03 19:10 ` [Bug c++/17287] Different class layout generated by g++ 3.3, 3.4 and 4.0 pinskia at gcc dot gnu dot org
@ 2004-10-12 5:54 ` mmitchel at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-10-12 5:54 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From mmitchel at gcc dot gnu dot org 2004-10-12 05:54 -------
G++ 3.3 used a slightly different C++ ABI from G++ 3.4 and G++ 3.5 (which has
now been renamed G++ 4.0). You can get the 3.3 C++ ABI in G++ 3.4/4.0 by using
-fabi-version=1. So, that explains the 3.3 vs. 3.4 difference.
You're comparing G++ 3.4 for powerpc-suse-linux with G++ 4.0 for
powerpc-apple-darwin. Darwin does not use the same structure layout rules as
GNU/Linux, so that is not a fair comparision. However, I do not think that is
making a difference in this case. The SuSE layout (12 bytes) is correct.
The G++ 4.0 results you display cannot be replicated with the mainline compiler
when compiling for powerpc-apple-darwin. You are using a very old version of
G++ 3.5 which was apparently distributed directly by Apple. You might want to
contact Apple directly about this issue.
Since the FSF version of G++ uses the correct 12-byte layout on
powerpc-apple-darwin, I have closed this PR.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17287
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2004-10-12 5:54 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-02 13:53 [Bug c++/17287] New: Different class layout generated by g++ 3.3, 3.4 and 3.5 yanliu at ca dot ibm dot com
2004-09-02 13:59 ` [Bug c++/17287] " yanliu at ca dot ibm dot com
2004-09-02 14:00 ` yanliu at ca dot ibm dot com
2004-09-02 14:00 ` yanliu at ca dot ibm dot com
2004-09-03 17:14 ` giovannibajo at libero dot it
2004-09-03 17:18 ` pinskia at gcc dot gnu dot org
2004-10-03 19:10 ` [Bug c++/17287] Different class layout generated by g++ 3.3, 3.4 and 4.0 pinskia at gcc dot gnu dot org
2004-10-12 5:54 ` mmitchel at gcc dot gnu dot 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).