public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/29910]  New: g++ compiled code SEGFAULTs if regparm(3) virtual destructor is overridden in a template derived class
@ 2006-11-20 12:07 massimiliano dot ghilardi at gmail dot com
  2006-11-20 13:50 ` [Bug c++/29910] " rguenth at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: massimiliano dot ghilardi at gmail dot com @ 2006-11-20 12:07 UTC (permalink / raw)
  To: gcc-bugs

This is the second of 3 related g++ bugs concerning regparm(3) on ix86.

Problem: g++ 3.4.6, 4.0.4, 4.1.2 (and possibly others) do not correctly handle
__attribute((regparm(3))) on virtual methods (in particular destructors)
overridden in a _template_ derived class.

If a Base class declares a virtual destructor with __attribute((regparm(3))),
and a _template_ Derived class overrides the destructor, the compiled program
will SEGFAULT
even if the Derived destructor is explicitly tagged __attribute((regparm(3)))

Test case:

--------------------------------------------------
// compile on ix86 with: g++ -Wall -O

class Base {
public:
    virtual __attribute((regparm(3))) ~Base() { }
};

template<class T> class Derived : public Base {
public:
    virtual __attribute((regparm(3))) ~Derived() { }
};

int main() {
    Base * s = new Derived<int>();
    delete s;

    return 0;
}
--------------------------------------------------

The test case above works correctly if the Derived class is NOT a template.


gcc versions tested: 3.4.6, 4.0.4, 4.1.2

>>>>> g++-3.4.6 -v <<<<<
Reading specs from /usr/lib/gcc/i486-linux-gnu/3.4.6/specs 
Configured with: ../src/configure -v --enable-languages=c,c++,f77,pascal
--prefix=/usr --libexecdir=/usr/lib --with-gxx-include-dir=/usr/include/c++/3.4
--enable-shared --with-system-zlib --enable-nls --without-included-gettext
--program-suffix=-3.4 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --with-tune=i686 i486-linux-gnu
Thread model: posix
gcc version 3.4.6 (Debian 3.4.6-4)

>>>>> g++-4.0.4 -v <<<<<
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,java
--prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--program-suffix=-4.0 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-java-awt=gtk-default --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre --with-tune=i686
--enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.0.4 20060904 (prerelease) (Debian 4.0.3-7)

>>>>> g++-4.1.2 -v <<<<<
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-mpfr --with-tune=i686
--enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-20)


-- 
           Summary: g++ compiled code SEGFAULTs if regparm(3) virtual
                    destructor is overridden in a template derived class
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: massimiliano dot ghilardi at gmail dot com
 GCC build triplet: i486-linux-gnu
  GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu


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


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

* [Bug c++/29910] g++ compiled code SEGFAULTs if regparm(3) virtual destructor is overridden in a template derived class
  2006-11-20 12:07 [Bug c++/29910] New: g++ compiled code SEGFAULTs if regparm(3) virtual destructor is overridden in a template derived class massimiliano dot ghilardi at gmail dot com
@ 2006-11-20 13:50 ` rguenth at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-11-20 13:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2006-11-20 13:50 -------
Confirmed.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
  GCC build triplet|i486-linux-gnu              |
   GCC host triplet|i486-linux-gnu              |
 GCC target triplet|i486-linux-gnu              |i?86-*-*
           Keywords|                            |wrong-code
      Known to fail|                            |4.1.2
   Last reconfirmed|0000-00-00 00:00:00         |2006-11-20 13:50:38
               date|                            |


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


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

end of thread, other threads:[~2006-11-20 13:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-20 12:07 [Bug c++/29910] New: g++ compiled code SEGFAULTs if regparm(3) virtual destructor is overridden in a template derived class massimiliano dot ghilardi at gmail dot com
2006-11-20 13:50 ` [Bug c++/29910] " rguenth 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).