Message ID | 3fbd71ab-22c8-d0d7-ffd1-83c8ee2b6ea1@oracle.com |
---|---|
State | New |
Headers | show |
Series | [C++] PR 80991 ("ICE with __is_trivially_constructible in template") | expand |
OK. On Wed, Oct 18, 2017 at 7:07 AM, Paolo Carlini <paolo.carlini@oracle.com> wrote: > Hi, > > a rather straightforward issue that we didn't notice so far only because in > all our uses of __is_trivially_constructible either neither type is > dependent or both are (eg, in library uses). The below handles in the > obvious way a possible TREE_LIST - built node by node by > cp_parser_trait_expr in the variadic case - as TRAIT_EXPR_TYPE2. Tested > x86_64-linux. Seems suitable for the branches too. > > Thanks, Paolo. > > /////////////////////// >
Index: cp/pt.c =================================================================== --- cp/pt.c (revision 253842) +++ cp/pt.c (working copy) @@ -24019,8 +24019,21 @@ value_dependent_expression_p (tree expression) case TRAIT_EXPR: { tree type2 = TRAIT_EXPR_TYPE2 (expression); - return (dependent_type_p (TRAIT_EXPR_TYPE1 (expression)) - || (type2 ? dependent_type_p (type2) : false)); + + if (dependent_type_p (TRAIT_EXPR_TYPE1 (expression))) + return true; + + if (!type2) + return false; + + if (TREE_CODE (type2) != TREE_LIST) + return dependent_type_p (type2); + + for (; type2; type2 = TREE_CHAIN (type2)) + if (dependent_type_p (TREE_VALUE (type2))) + return true; + + return false; } case MODOP_EXPR: Index: testsuite/g++.dg/ext/is_trivially_constructible5.C =================================================================== --- testsuite/g++.dg/ext/is_trivially_constructible5.C (nonexistent) +++ testsuite/g++.dg/ext/is_trivially_constructible5.C (working copy) @@ -0,0 +1,12 @@ +// PR c++/80991 +// { dg-do compile { target c++11 } } + +template<bool> void foo() +{ + static_assert(__is_trivially_constructible(int, int), ""); +} + +void bar() +{ + foo<true>(); +}