public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51331] New: bad code generated when explicitly calling auto-generated constructor of virtual base
@ 2011-11-28 12:18 zhezherun at yandex dot ru
  2011-11-29  5:28 ` [Bug c++/51331] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: zhezherun at yandex dot ru @ 2011-11-28 12:18 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51331
           Summary: bad code generated when explicitly calling
                    auto-generated constructor of virtual base
    Classification: Unclassified
           Product: gcc
           Version: 4.6.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: zhezherun@yandex.ru


If a virtual base class has an auto-generated default constructor, explicitly
calling it from the derived class' constructor can result in bad code. The
following stripped-down example reproduces the issue:


#include <iostream>

struct A {
    A(): x(10) {}
    virtual ~A() {}

    int x;
};

struct B: public virtual A {
};

struct C: public virtual A {
};

struct D: public B, virtual public C {
    D(): B(), C() {}  // note an explicit call to C() which is auto-generated
};

int main() {
    D* d = new D();
    std::cout << d->x << std::endl;

    // Crashes here with the following message:
    // *** glibc detected *** ./test: free(): invalid next size (fast)
    delete d;
}


This code used to work correctly in gcc 4.1.2 but crashes in gcc 4.6.2 on i386
(both -m32 and -m64).


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

* [Bug c++/51331] bad code generated when explicitly calling auto-generated constructor of virtual base
  2011-11-28 12:18 [Bug c++/51331] New: bad code generated when explicitly calling auto-generated constructor of virtual base zhezherun at yandex dot ru
@ 2011-11-29  5:28 ` pinskia at gcc dot gnu.org
  2011-11-29 10:09 ` zhezherun at yandex dot ru
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-11-29  5:28 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-11-29 05:01:12 UTC ---
This is a dup of bug 50618 which was fixed for 4.6.3 (and 4.4.7 and 4.5.5).

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


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

* [Bug c++/51331] bad code generated when explicitly calling auto-generated constructor of virtual base
  2011-11-28 12:18 [Bug c++/51331] New: bad code generated when explicitly calling auto-generated constructor of virtual base zhezherun at yandex dot ru
  2011-11-29  5:28 ` [Bug c++/51331] " pinskia at gcc dot gnu.org
@ 2011-11-29 10:09 ` zhezherun at yandex dot ru
  2011-11-29 13:11 ` paolo.carlini at oracle dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: zhezherun at yandex dot ru @ 2011-11-29 10:09 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Zhezherun <zhezherun at yandex dot ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
             Status|RESOLVED                    |UNCONFIRMED
           See Also|                            |http://gcc.gnu.org/bugzilla
                   |                            |/show_bug.cgi?id=50618
         Resolution|DUPLICATE                   |
      Known to fail|                            |4.6.2, 4.6.3

--- Comment #2 from Andrew Zhezherun <zhezherun at yandex dot ru> 2011-11-29 10:03:14 UTC ---
Reopened because this has not been fixed in latest gcc 4.6.x - I just tried
gcc-4.6-20111125 and my test case still crashes. Either this is a new issue or
the previous one has not been fully addressed. Please feel free to reopen
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50618 instead and attach this new
test case there if you prefer that.


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

* [Bug c++/51331] bad code generated when explicitly calling auto-generated constructor of virtual base
  2011-11-28 12:18 [Bug c++/51331] New: bad code generated when explicitly calling auto-generated constructor of virtual base zhezherun at yandex dot ru
  2011-11-29  5:28 ` [Bug c++/51331] " pinskia at gcc dot gnu.org
  2011-11-29 10:09 ` zhezherun at yandex dot ru
@ 2011-11-29 13:11 ` paolo.carlini at oracle dot com
  2011-12-14 23:40 ` [Bug c++/51331] [4.6/4.7 Regression] " pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-11-29 13:11 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011-11-29
                 CC|                            |jason at gcc dot gnu.org
     Ever Confirmed|0                           |1
      Known to fail|                            |4.7.0

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-11-29 11:54:15 UTC ---
I can see the glibc errors with current mainline.


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

* [Bug c++/51331] [4.6/4.7 Regression] bad code generated when explicitly calling auto-generated constructor of virtual base
  2011-11-28 12:18 [Bug c++/51331] New: bad code generated when explicitly calling auto-generated constructor of virtual base zhezherun at yandex dot ru
                   ` (2 preceding siblings ...)
  2011-11-29 13:11 ` paolo.carlini at oracle dot com
@ 2011-12-14 23:40 ` pinskia at gcc dot gnu.org
  2011-12-16 18:59 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-12-14 23:40 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.1.2
   Target Milestone|---                         |4.6.3
            Summary|bad code generated when     |[4.6/4.7 Regression] bad
                   |explicitly calling          |code generated when
                   |auto-generated constructor  |explicitly calling
                   |of virtual base             |auto-generated constructor
                   |                            |of virtual base


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

* [Bug c++/51331] [4.6/4.7 Regression] bad code generated when explicitly calling auto-generated constructor of virtual base
  2011-11-28 12:18 [Bug c++/51331] New: bad code generated when explicitly calling auto-generated constructor of virtual base zhezherun at yandex dot ru
                   ` (3 preceding siblings ...)
  2011-12-14 23:40 ` [Bug c++/51331] [4.6/4.7 Regression] " pinskia at gcc dot gnu.org
@ 2011-12-16 18:59 ` jason at gcc dot gnu.org
  2011-12-16 22:35 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2011-12-16 18:59 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |jason at gcc dot gnu.org
                   |gnu.org                     |


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

* [Bug c++/51331] [4.6/4.7 Regression] bad code generated when explicitly calling auto-generated constructor of virtual base
  2011-11-28 12:18 [Bug c++/51331] New: bad code generated when explicitly calling auto-generated constructor of virtual base zhezherun at yandex dot ru
                   ` (4 preceding siblings ...)
  2011-12-16 18:59 ` jason at gcc dot gnu.org
@ 2011-12-16 22:35 ` jason at gcc dot gnu.org
  2011-12-16 23:01 ` jason at gcc dot gnu.org
  2011-12-16 23:03 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2011-12-16 22:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2011-12-16 22:34:44 UTC ---
Author: jason
Date: Fri Dec 16 22:34:39 2011
New Revision: 182414

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182414
Log:
    PR c++/51331
    * class.c (convert_to_base_statically): Just call
    build_simple_base_path.
    (build_simple_base_path): Check field offset.

Added:
    trunk/gcc/testsuite/g++.dg/init/value10.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/class.c
    trunk/gcc/cp/init.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/51331] [4.6/4.7 Regression] bad code generated when explicitly calling auto-generated constructor of virtual base
  2011-11-28 12:18 [Bug c++/51331] New: bad code generated when explicitly calling auto-generated constructor of virtual base zhezherun at yandex dot ru
                   ` (5 preceding siblings ...)
  2011-12-16 22:35 ` jason at gcc dot gnu.org
@ 2011-12-16 23:01 ` jason at gcc dot gnu.org
  2011-12-16 23:03 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2011-12-16 23:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> 2011-12-16 22:59:32 UTC ---
Author: jason
Date: Fri Dec 16 22:59:27 2011
New Revision: 182418

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182418
Log:
    PR c++/51331
    * class.c (convert_to_base_statically): Just call
    build_simple_base_path.
    (build_simple_base_path): Check field offset.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/init/value10.C
Modified:
    branches/gcc-4_6-branch/gcc/cp/ChangeLog
    branches/gcc-4_6-branch/gcc/cp/class.c
    branches/gcc-4_6-branch/gcc/cp/init.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog


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

* [Bug c++/51331] [4.6/4.7 Regression] bad code generated when explicitly calling auto-generated constructor of virtual base
  2011-11-28 12:18 [Bug c++/51331] New: bad code generated when explicitly calling auto-generated constructor of virtual base zhezherun at yandex dot ru
                   ` (6 preceding siblings ...)
  2011-12-16 23:01 ` jason at gcc dot gnu.org
@ 2011-12-16 23:03 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2011-12-16 23:03 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Depends on|                            |50618
         Resolution|                            |FIXED

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> 2011-12-16 23:00:49 UTC ---
Fixed for 4.6.3/4.7.0


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

end of thread, other threads:[~2011-12-16 23:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-28 12:18 [Bug c++/51331] New: bad code generated when explicitly calling auto-generated constructor of virtual base zhezherun at yandex dot ru
2011-11-29  5:28 ` [Bug c++/51331] " pinskia at gcc dot gnu.org
2011-11-29 10:09 ` zhezherun at yandex dot ru
2011-11-29 13:11 ` paolo.carlini at oracle dot com
2011-12-14 23:40 ` [Bug c++/51331] [4.6/4.7 Regression] " pinskia at gcc dot gnu.org
2011-12-16 18:59 ` jason at gcc dot gnu.org
2011-12-16 22:35 ` jason at gcc dot gnu.org
2011-12-16 23:01 ` jason at gcc dot gnu.org
2011-12-16 23:03 ` jason at gcc dot gnu.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).