[PATCH] PR c++/55663 - constexpr function templ instantiation considered non-const as alias templ arg
Dodji Seketeli
dodji@redhat.com
Wed Jan 9 15:03:00 GMT 2013
Jason Merrill <jason@redhat.com> writes:
> On 01/08/2013 08:58 AM, Dodji Seketeli wrote:
>> 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.
>
> The problem is that by the time we get to check_instantiated_arg, we
> should have folded the expression into something
> TREE_CONSTANT. convert_template_argument should have done that; don't
> we ever call that function for this template argument?
Presumably, you mean that convert_template_argument should call
convert_nontype_argument to do that folding, right?
I guess the reason why it's not doing it is that the call to
convert_nontype_argument is conditional on
else if (!uses_template_parms (orig_arg) && !uses_template_parms (t))
/* We used to call digest_init here. However, digest_init
will report errors, which we don't want when complain
is zero. More importantly, digest_init will try too
hard to convert things: for example, `0' should not be
converted to pointer type at this point according to
the standard. Accepting this is not merely an
extension, since deciding whether or not these
conversions can occur is part of determining which
function template to call, or whether a given explicit
argument specification is valid. */
val = convert_nontype_argument (t, orig_arg, complain);
As the argument 'the_truth<T>()' we care about is type dependant,
uses_template_parms returns true and so convert_nontype_argument is
never called.
What is your preferred way want to handle this?
--
Dodji
More information about the Gcc-patches
mailing list