* [Bug c++/46526] VTable Problem?
2010-11-17 21:38 [Bug c++/46526] New: VTable Problem? nate.knight at numerica dot us
@ 2010-11-17 22:39 ` redi at gcc dot gnu.org
2010-11-18 10:09 ` [Bug c++/46526] [4.6 Regression] " rguenth at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2010-11-17 22:39 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46526
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2010.11.17 22:22:55
Ever Confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-11-17 22:22:55 UTC ---
struct Base
{
virtual int getid() = 0;
};
struct A : public Base
{
virtual int getid() { return 1; }
};
struct B : public Base
{
virtual int getid() { throw "here"; }
};
int main()
{
A a;
B b;
Base& ar = a;
ar.getid(); // throws
}
Only fails with 4.6.0 and -std=c++0x
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/46526] [4.6 Regression] VTable Problem?
2010-11-17 21:38 [Bug c++/46526] New: VTable Problem? nate.knight at numerica dot us
2010-11-17 22:39 ` [Bug c++/46526] " redi at gcc dot gnu.org
@ 2010-11-18 10:09 ` rguenth at gcc dot gnu.org
2010-11-18 14:29 ` redi at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2010-11-18 10:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46526
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Known to work| |4.5.1
Target Milestone|--- |4.6.0
Summary|VTable Problem? |[4.6 Regression] VTable
| |Problem?
--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2010-11-18 10:06:57 UTC ---
Confirmed.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/46526] [4.6 Regression] VTable Problem?
2010-11-17 21:38 [Bug c++/46526] New: VTable Problem? nate.knight at numerica dot us
2010-11-17 22:39 ` [Bug c++/46526] " redi at gcc dot gnu.org
2010-11-18 10:09 ` [Bug c++/46526] [4.6 Regression] " rguenth at gcc dot gnu.org
@ 2010-11-18 14:29 ` redi at gcc dot gnu.org
2010-11-19 8:58 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2010-11-18 14:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46526
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-11-18 14:23:52 UTC ---
4.6.0 20100925 was OK
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/46526] [4.6 Regression] VTable Problem?
2010-11-17 21:38 [Bug c++/46526] New: VTable Problem? nate.knight at numerica dot us
` (2 preceding siblings ...)
2010-11-18 14:29 ` redi at gcc dot gnu.org
@ 2010-11-19 8:58 ` jakub at gcc dot gnu.org
2010-11-19 9:47 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2010-11-19 8:58 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46526
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2010-11-19 08:56:05 UTC ---
Looks to me like a tree sharing problem in the FE, will debug it.
int
main ()
{
B b;
A a;
}
is in *.original as:
struct B b;
<<cleanup_point <<< Unknown tree: expr_stmt
(void) (b = TARGET_EXPR <D.1439, {.D.1372={._vptr.Base=&_ZTV1A + 16}}>)
>>>>>;
struct A a;
<<cleanup_point <<< Unknown tree: expr_stmt
(void) (a = TARGET_EXPR <D.1468, {.D.1363={._vptr.Base=&_ZTV1A + 16}}>)
>>>>>;
while
int
main ()
{
A a;
B b;
}
as:
struct A a;
<<cleanup_point <<< Unknown tree: expr_stmt
(void) (a = TARGET_EXPR <D.1439, {.D.1363={._vptr.Base=&_ZTV1B + 16}}>)
>>>>>;
struct B b;
<<cleanup_point <<< Unknown tree: expr_stmt
(void) (b = TARGET_EXPR <D.1468, {.D.1372={._vptr.Base=&_ZTV1B + 16}}>)
>>>>>;
One would expect a being initialized with _ZTV1A + 16 and b with _ZTV1B + 16 in
both cases...
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/46526] [4.6 Regression] VTable Problem?
2010-11-17 21:38 [Bug c++/46526] New: VTable Problem? nate.knight at numerica dot us
` (3 preceding siblings ...)
2010-11-19 8:58 ` jakub at gcc dot gnu.org
@ 2010-11-19 9:47 ` jakub at gcc dot gnu.org
2010-11-19 9:59 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2010-11-19 9:47 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46526
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu.org
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2010-11-19 09:04:14 UTC ---
Indeed, a tree sharing issue in C++ FE.
arg 1 <target_expr 0x7ffff18cac60 type <record_type 0x7ffff18d17e0 A>
side-effects constant
arg 0 <var_decl 0x7ffff19f1e60 D.1439 type <record_type 0x7ffff18d17e0
A>
ignored BLK file PQ.C line 19 col 5 size <integer_cst
0x7ffff19cf7a8 64> unit size <integer_cst 0x7ffff19cf7d0 8>
align 64 context <function_decl 0x7ffff18d0700 main>>
arg 1 <constructor 0x7ffff18dcaa0 type <record_type 0x7ffff18d17e0 A>
constant lngt 1 idx <field_decl 0x7ffff18d7390 D.1363>
val <constructor 0x7ffff18dca20 type <record_type 0x7ffff18d10a8
Base>
constant lngt 1 idx <field_decl 0x7ffff18d71c8 _vptr.Base>
val <pointer_plus_expr 0x7ffff7ffc3f0 type <pointer_type
0x7ffff18c8000>
readonly constant
arg 0 <addr_expr 0x7ffff18e6c00 type <pointer_type
0x7ffff18c8000>
readonly constant arg 0 <var_decl 0x7ffff19f13c0
_ZTV1A>>
arg 1 <integer_cst 0x7ffff19cf960 constant 16>>>>>>
and
arg 1 <target_expr 0x7ffff18cae10 type <record_type 0x7ffff18d1f18 B>
side-effects constant
arg 0 <var_decl 0x7ffff18f1140 D.1468 type <record_type 0x7ffff18d1f18
B>
ignored BLK file PQ.C line 20 col 5 size <integer_cst
0x7ffff19cf7a8 64> unit size <integer_cst 0x7ffff19cf7d0 8>
align 64 context <function_decl 0x7ffff18d0700 main>>
arg 1 <constructor 0x7ffff18dcc20 type <record_type 0x7ffff18d1f18 B>
constant lngt 1 idx <field_decl 0x7ffff18d75f0 D.1372>
val <constructor 0x7ffff18dca20 type <record_type 0x7ffff18d10a8
Base>
constant lngt 1 idx <field_decl 0x7ffff18d71c8 _vptr.Base>
val <pointer_plus_expr 0x7ffff7ffc578 type <pointer_type
0x7ffff18c8000>
readonly constant
arg 0 <addr_expr 0x7ffff18ed870 type <pointer_type
0x7ffff18c8000>
readonly constant arg 0 <var_decl 0x7ffff19f15a0
_ZTV1B>>
arg 1 <integer_cst 0x7ffff19cf960 constant 16>>>>>>
CONSTRUCTOR 0x7ffff18dca20 is shared in between those two expressions.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/46526] [4.6 Regression] VTable Problem?
2010-11-17 21:38 [Bug c++/46526] New: VTable Problem? nate.knight at numerica dot us
` (4 preceding siblings ...)
2010-11-19 9:47 ` jakub at gcc dot gnu.org
@ 2010-11-19 9:59 ` jakub at gcc dot gnu.org
2010-11-19 10:02 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2010-11-19 9:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46526
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> 2010-11-19 09:55:10 UTC ---
Created attachment 22454
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22454
gcc46-pr46526.patch
Possible fix. Not sure how often C++ FE tries to modify something within
expressions returned by cxx_eval_constant_expression. This patch is
conservative, perhaps might create too much garbage. On the other side,
looking at what is done in other parts of cxx_eval_constant_expression, it
usually just creates new trees and thus has the unsharing semantics in it.
If cxx_eval_bare_aggregate's:
/* Push our vtable pointer down into the base where it belongs. */
tree vptr_base = DECL_CONTEXT (ce->index);
tree base_ctor;
gcc_assert (ce->index == TYPE_VFIELD (type));
for (base_ctor = VEC_index (constructor_elt, n, 0)->value; ;
base_ctor = CONSTRUCTOR_ELT (base_ctor, 0)->value)
if (TREE_TYPE (base_ctor) == vptr_base)
{
constructor_elt *p = CONSTRUCTOR_ELT (base_ctor, 0);
gcc_assert (p->index == ce->index);
p->value = elt;
break;
}
is the only spot that actually tries to modify cxx_eval_constant_expression in
place, one could instead unshare it before starting to dive into the arguments,
but that could very well unshare twice e.g. all CONSTRUCTORS that went through
cxx_eval_bare_aggregate which created a new tree.
So this patch looks preferrable to me, but of course this is Jason's call what
to do.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/46526] [4.6 Regression] VTable Problem?
2010-11-17 21:38 [Bug c++/46526] New: VTable Problem? nate.knight at numerica dot us
` (5 preceding siblings ...)
2010-11-19 9:59 ` jakub at gcc dot gnu.org
@ 2010-11-19 10:02 ` jakub at gcc dot gnu.org
2010-11-19 23:53 ` jakub at gcc dot gnu.org
2010-11-20 0:05 ` jakub at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2010-11-19 10:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46526
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/46526] [4.6 Regression] VTable Problem?
2010-11-17 21:38 [Bug c++/46526] New: VTable Problem? nate.knight at numerica dot us
` (6 preceding siblings ...)
2010-11-19 10:02 ` jakub at gcc dot gnu.org
@ 2010-11-19 23:53 ` jakub at gcc dot gnu.org
2010-11-20 0:05 ` jakub at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2010-11-19 23:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46526
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> 2010-11-19 23:50:26 UTC ---
Author: jakub
Date: Fri Nov 19 23:50:21 2010
New Revision: 166967
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=166967
Log:
PR c++/46526
* semantics.c (cxx_eval_call_expression): Unshare the result.
* g++.dg/cpp0x/constexpr-base3.C: New test.
Added:
trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-base3.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/semantics.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/46526] [4.6 Regression] VTable Problem?
2010-11-17 21:38 [Bug c++/46526] New: VTable Problem? nate.knight at numerica dot us
` (7 preceding siblings ...)
2010-11-19 23:53 ` jakub at gcc dot gnu.org
@ 2010-11-20 0:05 ` jakub at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2010-11-20 0:05 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46526
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
AssignedTo|unassigned at gcc dot |jakub at gcc dot gnu.org
|gnu.org |
--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> 2010-11-19 23:53:46 UTC ---
Fixed.
^ permalink raw reply [flat|nested] 10+ messages in thread