On Tue, Jan 8, 2013 at 7:58 AM, Dodji Seketeli <do...@redhat.com> wrote:
> Hello,
>
> Consider the example of the problem report
>
>      1  template <typename>
>      2  constexpr bool the_truth () { return true; }
>      3
>      4  template <bool>
>      5    struct Takes_bool { };
>      6
>      7  template<bool B>
>      8    using Alias = Takes_bool<B>;
>      9
>     10  template<typename T>
>     11    struct test { using type = Alias<the_truth<T>()>; };
>     12
>     13  int main () {
>     14    test<int> a;
>     15
>     16    return 0;
>     17  }
>
> that yields the error:
>
>     test.cc: In substitution of ‘template<bool B> using Alias = Takes_bool<B> 
> [with bool B = the_truth<int>()]’:
>     test.cc:11:51:   required from ‘struct test<int>’
>     test.cc:14:13:   required from here
>     test.cc:11:51: error: integral expression ‘the_truth<int>()’ is not 
> constant
>        struct test { using type = Alias<the_truth<T>()>; };
>
> I think the issue happens in the course of instantiating test<int> at
> line 14, when we look into instantiating Alias<the_truth<T>()> (at
> line 11), with T = int.
>
> There, when we check the argument 'the_truth<int>()' to see if it
> actually is a constant expression, in check_instantiated_arg, we fail
> to recognize its constexpr-ness b/c we just look at its TREE_CONSTANT.

Thanks for the detective work!

We already have various predicates  to test for constant
expressions so I am uneasy to add yet another one.

What we do no need -- which I already suggested -- is a
predicate to test valid non-type template arguments.

For example, we already have the predicate verify_constant
and reduced_constant_expression_p, require_potential_constant_expression.

I think reduced_constant_expression_p is what you want.

-- Gaby

Reply via email to