Message ID | m38vveb3dw.fsf@redhat.com |
---|---|
State | New |
Headers | show |
diff --git a/gcc/cp/class.c b/gcc/cp/class.c index b6aebae..3216068 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5939,6 +5939,7 @@ fixed_type_or_null (tree instance, int *nonnull, int *cdtorp) itself. */ if (TREE_CODE (instance) == VAR_DECL && DECL_INITIAL (instance) + && !type_dependent_expression_p (DECL_INITIAL (instance)) && !htab_find (ht, instance)) { tree type; diff --git a/gcc/testsuite/g++.dg/template/dependent-expr7.C b/gcc/testsuite/g++.dg/template/dependent-expr7.C new file mode 100644 index 0000000..b246820 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/dependent-expr7.C @@ -0,0 +1,22 @@ +// Origin PR c++/48574 +// { dg-do compile } + +struct A +{ + virtual void foo(); +}; + +template <typename T> +void +bar(T x) +{ + A &b = *x; + b.foo (); +} + +void +foo() +{ + A a; + bar(&a); +}