public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13614] New: zero size base class not zero size in complex inheritance
@ 2004-01-08 15:21 lawless at spamcop dot net
  2004-01-08 15:23 ` [Bug c++/13614] " lawless at spamcop dot net
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: lawless at spamcop dot net @ 2004-01-08 15:21 UTC (permalink / raw)
  To: gcc-bugs

A zero size base class becomes one byte long in
a complex inheritance hierarchy.  Test case
illustrates this.  Compiles correctly with AIX V5
and Sun V7 compilers.

-- 
           Summary: zero size base class not zero size in complex
                    inheritance
           Product: gcc
           Version: 3.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: lawless at spamcop dot net
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i586-pc-linux-gnu
  GCC host triplet: i586-pc-linux-gnu
GCC target triplet: i586-pc-linux-gnu


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


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

* [Bug c++/13614] zero size base class not zero size in complex inheritance
  2004-01-08 15:21 [Bug c++/13614] New: zero size base class not zero size in complex inheritance lawless at spamcop dot net
@ 2004-01-08 15:23 ` lawless at spamcop dot net
  2004-01-08 16:08 ` [Bug c++/13614] [ABI] " bangerth at dealii dot org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: lawless at spamcop dot net @ 2004-01-08 15:23 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From lawless at spamcop dot net  2004-01-08 15:23 -------
Created an attachment (id=5434)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=5434&action=view)
test case


-- 


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


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

* [Bug c++/13614] [ABI] zero size base class not zero size in complex inheritance
  2004-01-08 15:21 [Bug c++/13614] New: zero size base class not zero size in complex inheritance lawless at spamcop dot net
  2004-01-08 15:23 ` [Bug c++/13614] " lawless at spamcop dot net
@ 2004-01-08 16:08 ` bangerth at dealii dot org
  2004-01-08 18:02 ` [Bug c++/13614] " pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: bangerth at dealii dot org @ 2004-01-08 16:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-01-08 16:08 -------
I can confirm that with all gcc versions and all setting of 
-fabi-version=... we get a size of 5, whereas icc gives us 4. 
Nathan, this one is so small that it should be easy to decide :-) 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nathan at gcc dot gnu dot
                   |                            |org
           Severity|normal                      |critical
            Summary|zero size base class not    |[ABI] zero size base class
                   |zero size in complex        |not zero size in complex
                   |inheritance                 |inheritance
   Target Milestone|---                         |3.4.0


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


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

* [Bug c++/13614] zero size base class not zero size in complex inheritance
  2004-01-08 15:21 [Bug c++/13614] New: zero size base class not zero size in complex inheritance lawless at spamcop dot net
  2004-01-08 15:23 ` [Bug c++/13614] " lawless at spamcop dot net
  2004-01-08 16:08 ` [Bug c++/13614] [ABI] " bangerth at dealii dot org
@ 2004-01-08 18:02 ` pinskia at gcc dot gnu dot org
  2004-01-08 19:07 ` nathan at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-08 18:02 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ABI, wrong-code
            Summary|[ABI] zero size base class  |zero size base class not
                   |not zero size in complex    |zero size in complex
                   |inheritance                 |inheritance


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


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

* [Bug c++/13614] zero size base class not zero size in complex inheritance
  2004-01-08 15:21 [Bug c++/13614] New: zero size base class not zero size in complex inheritance lawless at spamcop dot net
                   ` (2 preceding siblings ...)
  2004-01-08 18:02 ` [Bug c++/13614] " pinskia at gcc dot gnu dot org
@ 2004-01-08 19:07 ` nathan at gcc dot gnu dot org
  2004-01-09  0:05 ` lawless at spamcop dot net
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: nathan at gcc dot gnu dot org @ 2004-01-08 19:07 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From nathan at gcc dot gnu dot org  2004-01-08 19:07 -------
gcc is correct
Class D
   size=5 align=1
   base size=5 base align=1
D (0x4027cb00) 0
  B1 (0x4027cb40) 0 empty
  B3 (0x4027cb80) 1

B3 cannot be placed at offset zero in D, as that would create two different
B1 objects (the direct base of D and the direct base of the first B2 object
in B3's array member) at the same address.  That would violate a C++ invariant.


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


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


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

* [Bug c++/13614] zero size base class not zero size in complex inheritance
  2004-01-08 15:21 [Bug c++/13614] New: zero size base class not zero size in complex inheritance lawless at spamcop dot net
                   ` (3 preceding siblings ...)
  2004-01-08 19:07 ` nathan at gcc dot gnu dot org
@ 2004-01-09  0:05 ` lawless at spamcop dot net
  2004-01-09  0:08 ` lawless at spamcop dot net
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: lawless at spamcop dot net @ 2004-01-09  0:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From lawless at spamcop dot net  2004-01-09 00:05 -------
Disagree.  FOUR commercial compilers (Sun v7, IBM VAC v5, Intel 6 and Microsoft 
VC++6) do it "correctly."  G++ will be a less viable compiler if it fails to 
correct this deficiency.

The ISO spec states:

10.0(5) second sentence

While G++ is conforming to the "however" part of this,
the practical implication is very troublesome for embedded systems developers
who require absolute control over the size of their classes.

I'm getting increasingly fed-up with G++ and will be switching to ICC anyway, 
but I'm sure someone else will care.


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


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


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

* [Bug c++/13614] zero size base class not zero size in complex inheritance
  2004-01-08 15:21 [Bug c++/13614] New: zero size base class not zero size in complex inheritance lawless at spamcop dot net
                   ` (4 preceding siblings ...)
  2004-01-09  0:05 ` lawless at spamcop dot net
@ 2004-01-09  0:08 ` lawless at spamcop dot net
  2004-01-09  0:17 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: lawless at spamcop dot net @ 2004-01-09  0:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From lawless at spamcop dot net  2004-01-09 00:08 -------
Flubbed 10.0(5) paste:

A base class subobject may be of zero size (clause 9); however, two subobjects 
that have the same class type and that belong to the same most derived
object must not be allocated at the same address (5.10).

-- 


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


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

* [Bug c++/13614] zero size base class not zero size in complex inheritance
  2004-01-08 15:21 [Bug c++/13614] New: zero size base class not zero size in complex inheritance lawless at spamcop dot net
                   ` (5 preceding siblings ...)
  2004-01-09  0:08 ` lawless at spamcop dot net
@ 2004-01-09  0:17 ` pinskia at gcc dot gnu dot org
  2004-01-09  0:19 ` lawless at spamcop dot net
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-09  0:17 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-01-09 00:17 -------
Sorry but since this is the C++ standard you even quoted say that you are wrong, do not use C++ 
if you do not want to follow the standard (the other compilers are non-complaint then).

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


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


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

* [Bug c++/13614] zero size base class not zero size in complex inheritance
  2004-01-08 15:21 [Bug c++/13614] New: zero size base class not zero size in complex inheritance lawless at spamcop dot net
                   ` (6 preceding siblings ...)
  2004-01-09  0:17 ` pinskia at gcc dot gnu dot org
@ 2004-01-09  0:19 ` lawless at spamcop dot net
  2004-01-09  0:23 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: lawless at spamcop dot net @ 2004-01-09  0:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From lawless at spamcop dot net  2004-01-09 00:19 -------
You mean don't use G++.

Done.


-- 


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


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

* [Bug c++/13614] zero size base class not zero size in complex inheritance
  2004-01-08 15:21 [Bug c++/13614] New: zero size base class not zero size in complex inheritance lawless at spamcop dot net
                   ` (7 preceding siblings ...)
  2004-01-09  0:19 ` lawless at spamcop dot net
@ 2004-01-09  0:23 ` pinskia at gcc dot gnu dot org
  2004-01-09  0:30 ` lawless at spamcop dot net
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-09  0:23 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-01-09 00:23 -------
no I really mean do not use C++ (as you cannot call your stuff as C++ code if you do not follow 
the standard).

-- 


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


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

* [Bug c++/13614] zero size base class not zero size in complex inheritance
  2004-01-08 15:21 [Bug c++/13614] New: zero size base class not zero size in complex inheritance lawless at spamcop dot net
                   ` (8 preceding siblings ...)
  2004-01-09  0:23 ` pinskia at gcc dot gnu dot org
@ 2004-01-09  0:30 ` lawless at spamcop dot net
  2004-01-09 11:45 ` nathan at gcc dot gnu dot org
  2004-01-09 17:06 ` nathan at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: lawless at spamcop dot net @ 2004-01-09  0:30 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From lawless at spamcop dot net  2004-01-09 00:30 -------
A closer reading of

"however, two subobjects that have the same class type and that belong to the 
same most derived object must not be allocated at the same address (5.10)."

is in order.  The B1 base class does NOT appear twice in the same "most derived 
object".  B1 a base to a *member* of D *once*, and B1 is a base to D *once*.  B1 
does not appear as a base to any class more than one time.  G++ is wrong.


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


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


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

* [Bug c++/13614] zero size base class not zero size in complex inheritance
  2004-01-08 15:21 [Bug c++/13614] New: zero size base class not zero size in complex inheritance lawless at spamcop dot net
                   ` (9 preceding siblings ...)
  2004-01-09  0:30 ` lawless at spamcop dot net
@ 2004-01-09 11:45 ` nathan at gcc dot gnu dot org
  2004-01-09 17:06 ` nathan at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: nathan at gcc dot gnu dot org @ 2004-01-09 11:45 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From nathan at gcc dot gnu dot org  2004-01-09 11:45 -------
The part of the std you quote says 'sub objects' not 'base sub objects' do not
reside at the same address. The member of B3 is a sub obect of D. See the
definition of sub obect in [1.8]/2 which explicitly says a sub object
can be a member or a base. It also gives the algorithm for determining the
most derived object of any particular sub object. In this case,
the direct base B1 of D and the B1 base in the B3::v[0] member have the same
most derived object. Therefore they cannot be allocated at the same address.


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


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


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

* [Bug c++/13614] zero size base class not zero size in complex inheritance
  2004-01-08 15:21 [Bug c++/13614] New: zero size base class not zero size in complex inheritance lawless at spamcop dot net
                   ` (10 preceding siblings ...)
  2004-01-09 11:45 ` nathan at gcc dot gnu dot org
@ 2004-01-09 17:06 ` nathan at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: nathan at gcc dot gnu dot org @ 2004-01-09 17:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From nathan at gcc dot gnu dot org  2004-01-09 17:06 -------
I have tried the EDG 3.3 frontend, and that also gives a size of 5 for D,
thus I'd expect a later ICC release to do that too (I'm not sure which
version of ICC uses which EDG front end).

-- 


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


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

end of thread, other threads:[~2004-01-09 17:06 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-08 15:21 [Bug c++/13614] New: zero size base class not zero size in complex inheritance lawless at spamcop dot net
2004-01-08 15:23 ` [Bug c++/13614] " lawless at spamcop dot net
2004-01-08 16:08 ` [Bug c++/13614] [ABI] " bangerth at dealii dot org
2004-01-08 18:02 ` [Bug c++/13614] " pinskia at gcc dot gnu dot org
2004-01-08 19:07 ` nathan at gcc dot gnu dot org
2004-01-09  0:05 ` lawless at spamcop dot net
2004-01-09  0:08 ` lawless at spamcop dot net
2004-01-09  0:17 ` pinskia at gcc dot gnu dot org
2004-01-09  0:19 ` lawless at spamcop dot net
2004-01-09  0:23 ` pinskia at gcc dot gnu dot org
2004-01-09  0:30 ` lawless at spamcop dot net
2004-01-09 11:45 ` nathan at gcc dot gnu dot org
2004-01-09 17:06 ` nathan 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).