This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++ PATCH] [PR12573] fix ICE with offsetof as template argument (regression)


Hello Mark,

it seems that, after all, we still need to teach value_dependent_expression_p
to look into COMPONENT_REFs. Even if now they usually don't get there anymore
thanks to the strictier parser, we still can produce such a tree with offsetof,
because in that case the constaint are relaxed. Right now, we ICE deep into
tsubst because we think that the expression is non dependent.

I revamped my old patch for PR12573. Tested on i686-pc-linux-gnu, with no new
regressions. OK for mainline?

Giovanni Bajo


2004-01-08  Giovanni Bajo  <giovannibajo@gcc.gnu.org>

        PR c++/12573
        * pt.c (value_dependent_expression_p): Handle COMPONENT_REFs by
        looking into them recursively. They can be there because of the
        new __offsetof__ extension.

2004-01-08  Giovanni Bajo  <giovannibajo@gcc.gnu.org>

        PR c++/12573
        * g++.dg/template/dependent-expr4.C: New test.


Index: pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.808
diff -c -3 -p -r1.808 pt.c
*** pt.c        25 Dec 2003 16:28:50 -0000      1.808
--- pt.c        8 Jan 2004 03:40:44 -0000
*************** value_dependent_expression_p (tree expre
*** 11671,11676 ****
--- 11671,11679 ----
      }
    if (TREE_CODE (expression) == SCOPE_REF)
      return dependent_scope_ref_p (expression, value_dependent_expression_p);
+   if (TREE_CODE (expression) == COMPONENT_REF)
+     return (value_dependent_expression_p (TREE_OPERAND (expression, 0))
+           || value_dependent_expression_p (TREE_OPERAND (expression, 1)));
    /* A constant expression is value-dependent if any subexpression is
       value-dependent.  */
    if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (expression))))


// { dg-do compile }
// Origin: jbrandmeyer at users dot sourceforge dot net
// PR c++/12573: COMPONENT_REFs must be inspected for dependness.

template <bool> struct S;

template <typename K> struct Y {
  int x;
};

template <class T> struct Z {
  S< (bool)(__offsetof__(&static_cast<Y<T>*>(0)->x) == 0) >
    s;
};




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]