public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/18098] New: zero covarian return pointer adjustment results in segfault
@ 2004-10-21 16:54 boris at kolpackov dot net
  2004-10-21 17:13 ` [Bug c++/18098] zero covariant " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: boris at kolpackov dot net @ 2004-10-21 16:54 UTC (permalink / raw)
  To: gcc-bugs

$ cat >test.cxx 

struct base
{
};

struct derived : virtual base
{
};


struct base_parser
{
  virtual base*
  top () = 0;
};


struct derived_parser : virtual base_parser
{
  virtual derived*
  top ()
  {
    return 0;
    //return new derived;
  }
};

int
main ()
{
  base_parser* p = new derived_parser;
  base* b = p->top ();
}

$ g++-3.4 test.cxx 
bash-2.05a$ ./a.out 
Segmentation fault

-- 
           Summary: zero covarian return pointer adjustment results in
                    segfault
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: boris at kolpackov dot net
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-linux-gnu
  GCC host triplet: i686-linux-gnu
GCC target triplet: i686-linux-gnu


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


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

* [Bug c++/18098] zero covariant return pointer adjustment results in segfault
  2004-10-21 16:54 [Bug c++/18098] New: zero covarian return pointer adjustment results in segfault boris at kolpackov dot net
@ 2004-10-21 17:13 ` pinskia at gcc dot gnu dot org
  2004-10-21 20:13 ` bangerth at dealii dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-21 17:13 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-21 17:13 -------
Confirmed, the problem is the thunk.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2004-10-21 17:13:26
               date|                            |
            Summary|zero covarian return pointer|zero covariant return
                   |adjustment results in       |pointer adjustment results
                   |segfault                    |in segfault


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


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

* [Bug c++/18098] zero covariant return pointer adjustment results in segfault
  2004-10-21 16:54 [Bug c++/18098] New: zero covarian return pointer adjustment results in segfault boris at kolpackov dot net
  2004-10-21 17:13 ` [Bug c++/18098] zero covariant " pinskia at gcc dot gnu dot org
@ 2004-10-21 20:13 ` bangerth at dealii dot org
  2005-01-20  6:14 ` pinskia at gcc dot gnu dot org
  2005-04-22  5:11 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: bangerth at dealii dot org @ 2004-10-21 20:13 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-10-21 20:13 -------
BTW, this never worked: up to 3.3.x, gcc emits a sorry() because the 
necessary thunking abilities weren't in place. Since then the code 
compiles but the executable segfaults. 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nathan at gcc dot gnu dot
                   |                            |org
      Known to fail|                            |2.95.3 3.2.3 3.3.4 3.4.2
                   |                            |4.0.0


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


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

* [Bug c++/18098] zero covariant return pointer adjustment results in segfault
  2004-10-21 16:54 [Bug c++/18098] New: zero covarian return pointer adjustment results in segfault boris at kolpackov dot net
  2004-10-21 17:13 ` [Bug c++/18098] zero covariant " pinskia at gcc dot gnu dot org
  2004-10-21 20:13 ` bangerth at dealii dot org
@ 2005-01-20  6:14 ` pinskia at gcc dot gnu dot org
  2005-04-22  5:11 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-20  6:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-20 06:14 -------
We can easy see the problem on the mainline by looking at the tree dumps:
  [pr18098.cc : 31] D.1709 = [pr18098.cc : 31] top (this);
  [pr18098.cc : 31] D.1707 = D.1709;
  [pr18098.cc : 31] D.1710 = D.1707;
  [pr18098.cc : 31] D.1711 = (int (*__vtbl_ptr_type) (void) * *) D.1710;
  [pr18098.cc : 31] D.1712 = *D.1711;


Note how we dereference D.1711 but this is also the return value from top where the problem comes 
from.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org


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


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

* [Bug c++/18098] zero covariant return pointer adjustment results in segfault
  2004-10-21 16:54 [Bug c++/18098] New: zero covarian return pointer adjustment results in segfault boris at kolpackov dot net
                   ` (2 preceding siblings ...)
  2005-01-20  6:14 ` pinskia at gcc dot gnu dot org
@ 2005-04-22  5:11 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-22  5:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-04-22 05:10 -------


*** This bug has been marked as a duplicate of 20746 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


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


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

end of thread, other threads:[~2005-04-22  5:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-21 16:54 [Bug c++/18098] New: zero covarian return pointer adjustment results in segfault boris at kolpackov dot net
2004-10-21 17:13 ` [Bug c++/18098] zero covariant " pinskia at gcc dot gnu dot org
2004-10-21 20:13 ` bangerth at dealii dot org
2005-01-20  6:14 ` pinskia at gcc dot gnu dot org
2005-04-22  5:11 ` pinskia 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).