Bug 14020 - template keyword used as a disambiguator not conforming to ISO C++ 98
Summary: template keyword used as a disambiguator not conforming to ISO C++ 98
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-04 20:27 UTC by Bernardo Innocenti
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bernardo Innocenti 2004-02-04 20:27:24 UTC
The attached testcase, extracted from the AC_CXX_TEMPLATE_KEYWORD_QUALIFIER
macro, produces the following error with 3.4 and tree-ssa:

 foo.cc: In function `int main()':
 foo.cc:9: error: `template' (as a disambiguator) is only allowed within templates

Used to work fine back in 3.3.2.

According to the standard (14.2/4):

 When the name of a member template specialization appears
 after . or -> in a postfix-expression, or after
 nested-name-specifier in a qualified-id, and the
 postfix-expression or qualified-id explicitly depends on a
 template-parameter (14.6.2), the member template name must
 be prefixed by the keyword template.
 Otherwise the name is assumed to name a non-template.
Comment 1 Andrew Pinski 2004-02-04 22:24:07 UTC
I think the part that really applies here is "and the
 postfix-expression or qualified-id explicitly depends on a
 template-parameter (14.6.2)" part so this bug is invalid.

The other part that applies is in the note of 14.2/5: "Note: the keyword template may not be applied to 
non-template members of class templates. ".

Unless you can prove otherwise with a source showing what the problem is, I am closing this bug as 
invalid.
Comment 2 Wolfgang Bangerth 2004-02-04 22:29:58 UTC
There has been a clarification in one DR that "template" is only required 
if the part BEFORE the dot or :: is actually dependent on a template 
parameter. This was missing from the standard. 
 
That being said, show us some code and we can check your claim. 
 
W. 
Comment 3 Bernardo Innocenti 2004-02-04 22:54:55 UTC
Sorry, I thought I had aborted this bug filing, but eventually
Mozilla submitted the form when I opened another URL in the
same window ;-)

The problem has been cleared with the ac-archive people and
I'm going to submit an updated configure test.

This was the failing testcase from
ac_cxx_template_keyword_qualifier.m4:

 class A {
 public:
       A() {};
       template<class T> static T convert() { return T(); }
 };

 int main ()
 {
         double z = A::template convert<double>();
         return 0;
 }

And this is what the updated configure test
should look like:

 class X {
 public:
        template<int> void member() { }
        template<int> static void static_member() { }
 };
 template<class T> void f(T* p)
 {
        p->template member<200>(); // OK: < starts template argument list
        T::template static_member<100>(); // OK: < starts explicit qualification
 }
 int main()
 {
	X x;
	f(&x);
        return 0;
 }
Comment 4 Wolfgang Bangerth 2004-02-05 00:11:54 UTC
This was exactly the case I was talking about. In your first example, 
A is not template dependent, so A::convert<double> shouldn't have 
the "template" in the middle. 
 
W. 
Comment 5 Gabriel Dos Reis 2004-02-05 00:31:58 UTC
Subject: Re:  template keyword used as a disambiguator not conforming to ISO C++ 98

"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:

| This was exactly the case I was talking about. In your first example, 
| A is not template dependent, so A::convert<double> shouldn't have 
| the "template" in the middle. 

More precisely, the informaous "::template" is not allowed outside of
a template code.  However, it is allowed in a template even if the
name preceding it is not dependent.

-- Gaby
Comment 6 Giovanni Bajo 2004-02-05 02:16:43 UTC
> More precisely, the informaous "::template" is not allowed outside of
> a template code.  However, it is allowed in a template even if the
> name preceding it is not dependent.

... which, by the way, is exactly what our diagnostic says:

foo.cc:9: error: `template' (as a disambiguator) is only allowed within 
templates
Comment 7 Gabriel Dos Reis 2004-02-05 02:43:56 UTC
Subject: Re:  template keyword used as a disambiguator not conforming to ISO C++ 98

"giovannibajo at libero dot it" <gcc-bugzilla@gcc.gnu.org> writes:

| > More precisely, the informaous "::template" is not allowed outside of
| > a template code.  However, it is allowed in a template even if the
| > name preceding it is not dependent.
| 
| ... which, by the way, is exactly what our diagnostic says:
| 
| foo.cc:9: error: `template' (as a disambiguator) is only allowed within 
| templates

I was adding a precision to the message I was replying to which were
implying that the name before "::template" ought to be dependent.

-- Gaby
Comment 8 Volker Reichelt 2004-07-13 20:16:55 UTC
Reopening ...
Comment 9 Volker Reichelt 2004-07-13 20:17:20 UTC
... to close as invalid.