| Submitter | Paolo Carlini |
|---|---|
| Date | June 30, 2010, 6:35 p.m. |
| Message ID | <4C2B8E61.90807@oracle.com> |
| Download | mbox | patch |
| Permalink | /patch/57445/ |
| State | New |
| Headers | show |
Comments
OK. Jason
On Wed, Jun 30, 2010 at 8:35 PM, Paolo Carlini <paolo.carlini@oracle.com> wrote: > Hi, > > a simple patch for this P2 regression. As for the rationale behind the > additional checks: the one in cp_build_unary_op seems rather sensible > considering how many uses the function has; the other is justified > because in the caller, reference_binding, expr can be certainly > NULL_TREE in general (we already check for expr non-NULL_TREE in many > places). > > Tested x86_64-linux. Ok for mainline and 4_5-branch? The trunk was frozen when you committed this patch. Thanks, Richard. > Paolo. > > //////////////////// >
Patch
Index: testsuite/g++.dg/template/crash100.C =================================================================== --- testsuite/g++.dg/template/crash100.C (revision 0) +++ testsuite/g++.dg/template/crash100.C (revision 0) @@ -0,0 +1,24 @@ +// PR c++/44628 + +template <typename T> +class Temp +{ + int Val; + public: + operator T&(void) { return Val; } + + virtual T& operator=(T a ) // { dg-error "overriding" } + { + Val = a; + return Val; + } +}; + +class Int : public Temp<int> +{ + public: + Int& operator=(int a) // { dg-error "conflicting return type" } + { + return (*this); + } +}; Index: cp/typeck.c =================================================================== --- cp/typeck.c (revision 161612) +++ cp/typeck.c (working copy) @@ -4781,7 +4781,7 @@ cp_build_unary_op (enum tree_code code, tree xarg, tree val; const char *invalid_op_diag; - if (error_operand_p (arg)) + if (!arg || error_operand_p (arg)) return error_mark_node; if ((invalid_op_diag Index: cp/call.c =================================================================== --- cp/call.c (revision 161612) +++ cp/call.c (working copy) @@ -1040,6 +1040,9 @@ convert_class_to_reference (tree reference_type, t struct z_candidate *cand; bool any_viable_p; + if (!expr) + return NULL; + conversions = lookup_conversions (s, /*lookup_template_convs_p=*/true); if (!conversions) return NULL;