public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/19604] New: vtable error with virtual inheritance and tables
@ 2005-01-24 14:28 webmyster at addoc dot u-psud dot fr
  2005-01-24 14:31 ` [Bug c++/19604] " webmyster at addoc dot u-psud dot fr
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: webmyster at addoc dot u-psud dot fr @ 2005-01-24 14:28 UTC (permalink / raw)
  To: gcc-bugs

I don't know if it's a bug in g++ or a lack in the specifications of C++ ...

I define two classes, one inherited from the second. I allocate a table of the
child, I give it to a fonction that waits for the parent class.

Inside this function, when I try to access virtual functions of an element of
the table other than the first, I get a segfault.
It seems to be that in this function, the size of each element of the table is
considered to be the one of the parent but not the one of the child. That
induces a memory shift that segfault when trying to accessing the vtable ...

Is there the size of the object inside the vtable ?

-- 
           Summary: vtable error with virtual inheritance and tables
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: webmyster at addoc dot u-psud dot fr
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i686-pc-linux


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


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

* [Bug c++/19604] vtable error with virtual inheritance and tables
  2005-01-24 14:28 [Bug c++/19604] New: vtable error with virtual inheritance and tables webmyster at addoc dot u-psud dot fr
@ 2005-01-24 14:31 ` webmyster at addoc dot u-psud dot fr
  2005-01-24 14:37 ` [Bug c++/19604] vtable error with virtual inheritance and arrays pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: webmyster at addoc dot u-psud dot fr @ 2005-01-24 14:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From webmyster at addoc dot u-psud dot fr  2005-01-24 14:31 -------
Created an attachment (id=8053)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=8053&action=view)
vtable error with virtual inheritance and tables

This file shows two things :
* the size of one element is different according to the context (parent class
or child class) ;
* this difference induce a segfault when trying to acces virtual function
"VirtualAdresse()".

-- 


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


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

* [Bug c++/19604] vtable error with virtual inheritance and arrays
  2005-01-24 14:28 [Bug c++/19604] New: vtable error with virtual inheritance and tables webmyster at addoc dot u-psud dot fr
  2005-01-24 14:31 ` [Bug c++/19604] " webmyster at addoc dot u-psud dot fr
@ 2005-01-24 14:37 ` pinskia at gcc dot gnu dot org
  2005-01-24 14:53 ` webmyster at addoc dot u-psud dot fr
  2005-01-26  4:25 ` bangerth at dealii dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-24 14:37 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-24 14:37 -------
I think this is invalid and here is why?
Basically the sizeof (A) is smaller than sizeof(B).
But if you convert from B* to A* you cannot access the second element any more.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|vtable error with virtual   |vtable error with virtual
                   |inheritance and tables      |inheritance and arrays


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


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

* [Bug c++/19604] vtable error with virtual inheritance and arrays
  2005-01-24 14:28 [Bug c++/19604] New: vtable error with virtual inheritance and tables webmyster at addoc dot u-psud dot fr
  2005-01-24 14:31 ` [Bug c++/19604] " webmyster at addoc dot u-psud dot fr
  2005-01-24 14:37 ` [Bug c++/19604] vtable error with virtual inheritance and arrays pinskia at gcc dot gnu dot org
@ 2005-01-24 14:53 ` webmyster at addoc dot u-psud dot fr
  2005-01-26  4:25 ` bangerth at dealii dot org
  3 siblings, 0 replies; 5+ messages in thread
From: webmyster at addoc dot u-psud dot fr @ 2005-01-24 14:53 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From webmyster at addoc dot u-psud dot fr  2005-01-24 14:53 -------
(In reply to comment #2)
> I think this is invalid and here is why?
> Basically the sizeof (A) is smaller than sizeof(B).
> But if you convert from B* to A* you cannot access the second element any more.

I'm agree it's not a conventional use of inheritance and tables. But it may be
valid.
Where could I find the C++ specifications used to implement g++, to get a valid
solution to my problem ?

Moreover, I would like to have a warning during the compilation. I think the
compiler can warning on each call of non first element of a table of classes
containing vtable.

-- 


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


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

* [Bug c++/19604] vtable error with virtual inheritance and arrays
  2005-01-24 14:28 [Bug c++/19604] New: vtable error with virtual inheritance and tables webmyster at addoc dot u-psud dot fr
                   ` (2 preceding siblings ...)
  2005-01-24 14:53 ` webmyster at addoc dot u-psud dot fr
@ 2005-01-26  4:25 ` bangerth at dealii dot org
  3 siblings, 0 replies; 5+ messages in thread
From: bangerth at dealii dot org @ 2005-01-26  4:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2005-01-26 04:25 -------
You are accessing something here  
  var[1].adresse() 
that definitely is not an A, but sitting somewhere between other 
objects. That's definitely not allowed. 
 
W. 

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


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


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

end of thread, other threads:[~2005-01-26  4:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-24 14:28 [Bug c++/19604] New: vtable error with virtual inheritance and tables webmyster at addoc dot u-psud dot fr
2005-01-24 14:31 ` [Bug c++/19604] " webmyster at addoc dot u-psud dot fr
2005-01-24 14:37 ` [Bug c++/19604] vtable error with virtual inheritance and arrays pinskia at gcc dot gnu dot org
2005-01-24 14:53 ` webmyster at addoc dot u-psud dot fr
2005-01-26  4:25 ` bangerth at dealii 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).