This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/17413] [3.4/4.0 regression] local classes as template argument
- From: "gdr at integrable-solutions dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Sep 2004 23:15:30 -0000
- Subject: [Bug c++/17413] [3.4/4.0 regression] local classes as template argument
- References: <20040911043255.17413.gdr@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From gdr at integrable-solutions dot net 2004-09-12 23:15 -------
Subject: Re: [3.4/4.0 regression] local classes as template argument
"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:
| This is related to the substitution-failure-is-not-an-error thingy: we
| realize that a local class cannot be matched against a template argument,
| so we drop the template function std::for_each from the overload list --
| and end up with an empty list, thus the error message.
Indeed, the whole problem is in pt.c:check_instantiated_args(). It
contains code for proper diagnostic
tree nt = no_linkage_check (t, /*relaxed_p=*/false);
if (nt)
{
if (!(complain & tf_error))
/*OK*/;
else if (TYPE_ANONYMOUS_P (nt))
error ("`%T' uses anonymous type", t);
else
error ("`%T' uses local type `%T'", t, nt);
result = true;
}
But the diagnostic is not emitted because tf_error is not set in
complain.
| We probably need to special-case the overload resolution process to handle
| this case: when we end up with an empty overload list but there is a
| function that would match were it not for a local class, we should report
| so. Whether this kind of special-casing is desirable is another matter.
I would say it is a Suboptimal implementation of SFINAE.
In the phase where the overload-set is constructed, indeed SFINAE
is applied -- if something is invalid, just bail out without spitting
any diagnostic. However, once the overload-set is constructed, any
error is an error.
Notice that Comeau online really does give an informative diagnostic
"ComeauTest.c", line 11: error: a template argument may not reference
a local type
std::for_each(a, a + 10, T());
^
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17413