[C++ RFC / patch] PR 32674

Paolo Carlini pcarlini@suse.de
Thu Sep 6 12:33:00 GMT 2007


Hi all, hi Mark,

I'm trying to make progress on this PR, a P1 regression, ice-on-valid.
I'm going to tell you what I learned, also taking inspiration from the
fix for 31992.

----------------------- snip -----------------------
class C
{
  static const int j = 3;
};

template<int> class A
{
    static const int i;
};

template<int N> const int A<N>::i(C::j);
----------------------- snip -----------------------

For C::j, in cp_finish_decl I'm seeing this init tree:

 <tree_list 0x2aef70e8c270
    value <scope_ref 0x2aef70e6ffc0
        type <integer_type 0x2aef70e82410 int readonly type_6 SI
            size <integer_cst 0x2aef70721a50 constant invariant 32>
            unit size <integer_cst 0x2aef707216c0 constant invariant 4>
            align 32 symtab 0 alias set -1 canonical type 0x2aef70e82410
precision 32 min <integer_cst 0x2aef707219c0 -2147483648> max
<integer_cst 0x2aef707219f0 2147483647>>
        readonly
        arg 0 <record_type 0x2aef70e820d0 C type_1 type_5 type_6 QI
            size <integer_cst 0x2aef707217b0 constant invariant 8>
            unit size <integer_cst 0x2aef707217e0 constant invariant 1>
            align 8 symtab 0 alias set -1 canonical type 0x2aef70e820d0
fields <var_decl 0x2aef70e3bd10 j>
            X() X(constX&) this=(X&) n_parents=0 use_template=0
interface-unknown
            chain <type_decl 0x2aef70e821a0 C>>
        arg 1 <var_decl 0x2aef70e3bd10 j type <integer_type
0x2aef70e82410 int>
            readonly constant used public static tree_1 tree_2 tree_3
external nonlocal decl_3 decl_5 decl_6 SI file 32674.C line 5 size
<integer_cst 0x2aef70721a50 32> unit size <integer_cst 0x2aef707216c0 4>
            align 32 context <record_type 0x2aef70e820d0 C> initial
<integer_cst 0x2aef7075e510 3>
            chain <type_decl 0x2aef70e82270 C>>>>

as you can see, we have a SCOPE_REF in a TREE_LIST.

At variance, with the testcase in 31992, we have that
value_dependent_init_p(init) is false (rightfully so, in my opinion),
and the special code for integral constant static data members in
templates is not used. Instead, we get directly to line 5336, the generic:

    init = fold_non_dependent_expr (init);

now the problem is that the code in it refuses to tsubst_copy_and_build
the init tree, because type_dependent_expression_p turns out to be true
(*not* rightfully so, AFAICS): type_dependent_expr_p doesn't know how to
deal with TREE_LIST, therefore doesn't recognize directly that in this
case it boils down to a SCOPE_REF as TREE_VALUE, and resorts to
dependent_type_p(TREE_TYPE (expression)) which returns true by default
since TREE_TYPE(expression) is a NULL_TREE. Thus the idea for the
draft-draft patch (which passes testing).

So, this is where I am, at the moment... Any help to make further progress?

Thanks,
Paolo.

/////////////////
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: p
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070906/30bc86c4/attachment.ksh>


More information about the Gcc-patches mailing list