public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/12377] New: Empty base out of class boundaries
@ 2003-09-23 15:57 grigory at stl dot sarov dot ru
  2003-09-23 16:02 ` [Bug c++/12377] [ABI] " bangerth at dealii dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: grigory at stl dot sarov dot ru @ 2003-09-23 15:57 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: Empty base out of class boundaries
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: grigory at stl dot sarov dot ru
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-redhat-linux
  GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux

Using the 3.2-compatable ABI implementation (-fabi_version=1) g++ compiler may 
alocate empty virtual base out of class boundaries. That seems to be a bug 
rather than a specific implementation.

Let's see: on class hierarchy listed below, g++ 3.3.1 produces class c17 of 
size 16 but allocates c17::c10::c0 base at offset 28.

$ cat foo.cpp
struct c0 { };
struct c2 {
    unsigned char m1;
};
struct c5 : c0, virtual c2 { };
struct c6 { };
struct c9 : c5, c6 { };
struct c10 :
    virtual c2,
    virtual c5,
    virtual c0,
    c9
{
};
struct c17 : virtual c10, c6 { };


$ g++ -c -fdump-class-hierarchy foo.cpp
Class c17
   size=16 align=4
c17 (0x4032d400) 0
    vptridx=0 vptr=((&c17::_ZTV3c17) + 24)
  c10 (0x4032d440) 0 nearly-empty virtual canonical
	...
    c0 (0x4032d5c0) 28 empty virtual canonical

Of cource an empty base does not take any space there, but the class object 
become logically invalid and potentially may lead to run-time problems.


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

* [Bug c++/12377] [ABI] Empty base out of class boundaries
  2003-09-23 15:57 [Bug c++/12377] New: Empty base out of class boundaries grigory at stl dot sarov dot ru
@ 2003-09-23 16:02 ` bangerth at dealii dot org
  2003-09-24  9:13 ` nathan at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: bangerth at dealii dot org @ 2003-09-23 16:02 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Empty base out of class     |[ABI] Empty base out of
                   |boundaries                  |class boundaries


------- Additional Comments From bangerth at dealii dot org  2003-09-23 14:43 -------
I can confirm this, but I have no clue what is supposed to be
the right value. 

What is interesting, though, is that present mainline ICEs while
writing out the class info.

W.


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

* [Bug c++/12377] [ABI] Empty base out of class boundaries
  2003-09-23 15:57 [Bug c++/12377] New: Empty base out of class boundaries grigory at stl dot sarov dot ru
  2003-09-23 16:02 ` [Bug c++/12377] [ABI] " bangerth at dealii dot org
@ 2003-09-24  9:13 ` nathan at gcc dot gnu dot org
  2003-09-24  9:40 ` nathan at gcc dot gnu dot org
  2003-12-09 18:30 ` dhazeghi at yahoo dot com
  3 siblings, 0 replies; 5+ messages in thread
From: nathan at gcc dot gnu dot org @ 2003-09-24  9:13 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


nathan at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |nathan at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED


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

* [Bug c++/12377] [ABI] Empty base out of class boundaries
  2003-09-23 15:57 [Bug c++/12377] New: Empty base out of class boundaries grigory at stl dot sarov dot ru
  2003-09-23 16:02 ` [Bug c++/12377] [ABI] " bangerth at dealii dot org
  2003-09-24  9:13 ` nathan at gcc dot gnu dot org
@ 2003-09-24  9:40 ` nathan at gcc dot gnu dot org
  2003-12-09 18:30 ` dhazeghi at yahoo dot com
  3 siblings, 0 replies; 5+ messages in thread
From: nathan at gcc dot gnu dot org @ 2003-09-24  9:40 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


nathan at gcc dot gnu dot org changed:

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


------- Additional Comments From nathan at gcc dot gnu dot org  2003-09-24 09:13 -------
This is fixed in 3.4, 
* use -Wabi to warn about it
* use -fabi-version=0 to resolve it

The ICE is now fixed, it was a pretty printer problem


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

* [Bug c++/12377] [ABI] Empty base out of class boundaries
  2003-09-23 15:57 [Bug c++/12377] New: Empty base out of class boundaries grigory at stl dot sarov dot ru
                   ` (2 preceding siblings ...)
  2003-09-24  9:40 ` nathan at gcc dot gnu dot org
@ 2003-12-09 18:30 ` dhazeghi at yahoo dot com
  3 siblings, 0 replies; 5+ messages in thread
From: dhazeghi at yahoo dot com @ 2003-12-09 18:30 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |3.4


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


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

end of thread, other threads:[~2003-12-09 18:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-23 15:57 [Bug c++/12377] New: Empty base out of class boundaries grigory at stl dot sarov dot ru
2003-09-23 16:02 ` [Bug c++/12377] [ABI] " bangerth at dealii dot org
2003-09-24  9:13 ` nathan at gcc dot gnu dot org
2003-09-24  9:40 ` nathan at gcc dot gnu dot org
2003-12-09 18:30 ` dhazeghi at yahoo dot com

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