http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55677
vlukas at gmx dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |vlukas at gmx dot de
--- Comment #5 from vlukas at gmx dot de 2012-12-14 18:52:14 UTC ---
I can reproduce the crash.
I believe this can be reduced to an illegal conversion to a virtual base:
If you do not pass "this" as an argument to "new class2" in the "derived"
default constructor and instead pass the address of a fully constructed
"derived" object, the program does not crash. I will post an attachment, which
is a modification the original submitters attachment from today.
On the other hand the following program crashes, which is a further reduction
of the submitters testcase:
------------------------------------------------------------------------------
struct base
{
base(int = 0) { }
};
struct middle : public virtual base
{
middle() { }
};
struct class2
{
class2(middle *var)
{
base* p = var;
}
};
struct derived : public middle
{
derived() : base((class2(this), 0)) { }
};
int main()
{
new derived;
}
------------------------------------------------------------------------------
I believe this violates 12.7 " Construction and destruction", paragraph 3,
because when initializing the "base" subobject of the "derived" object, the
construction of "middle" has not yet started.
FYI, a backtrace of the submitters original testcase and mine look similar.
------------------------ original: -------------------------------------------
#0 0x00000000004022f1 in class2::class2 (this=0x607010, var=0x7fffffffd950) at
orig_one_file.cc:82
#1 0x0000000000402494 in derived::derived (this=0x7fffffffd950,
__in_chrg=<optimized out>,
__vtt_parm=<optimized out>) at orig_one_file.cc:104
#2 0x0000000000401cac in main () at orig_one_file.cc:118
------------------------------------------------------------------------------
----------------------- mine: ------------------------------------------------
#0 0x00000000004008e9 in class2::class2 (this=0x7fffffffd957, var=0x602010) at
main_reduced.cc:15
#1 0x0000000000400946 in derived::derived (this=0x602010, __in_chrg=<optimized
out>,
__vtt_parm=<optimized out>) at main_reduced.cc:22
#2 0x0000000000400825 in main () at main_reduced.cc:27
------------------------------------------------------------------------------
(Note: The backtrace corresponds to the much reduced snippet above, not to the
code I will attach.)
I hope my reasoning goes in the right direction, but I leave final judgement
whether my reduced testcase reproduces the orignal problem and whether the code
is in fact illegal to the GCC maintainers and to the submitter.