Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 14566
Product:  
Component:  
Status: RESOLVED
Resolution: DUPLICATE of bug 15503
Assigned To: Giovanni Bajo <giovannibajo@libero.it>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: ron hylton <ron_hylton@hotmail.com>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 14566 depends on: Show dependency tree
Show dependency graph
Bug 14566 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2004-03-13 07:16 Opened: 2004-03-13 06:43
The 'template' disambiguator keyword on the base of B below causes the 
following error: "expected class-name before '{' token".  This code compiles in 
GCC 3.3.1.  Test case:

struct A
{
	template <class F>
	struct X
	{
	};
};

template <class F>
struct B : public A::template X<F>
{
};

gcc -v output:
Reading specs from /gcc-3.4/lib/gcc/i686-pc-cygwin/3.4.0/specs
Configured with: ../gcc/configure --prefix=/gcc-3.4 --enable-languages=c,c++,f77
--enable-libgcj --enable-threads=posix --with-system-zlib --enable-nls --withou
t-included-gettext --enable-interpreter --enable-version-specific-runtime-libs -
-enable-shared --disable-win32-registry --enable-java-gc=boehm --disable-hash-sy
nchronization --verbose
Thread model: posix
gcc version 3.4.0 20040312 (prerelease)

------- Comment #1 From Andrew Pinski 2004-03-13 07:16 -------
Confirmed a regression from 3.3.1.

------- Comment #2 From Wolfgang Bangerth 2004-03-14 20:26 -------
I think I recall that the disambiguator was not allowed here. 
Giovanni, somehow I recall that you said that before, do you happen 
to know? 
 
W. 

------- Comment #3 From Giovanni Bajo 2004-03-15 02:02 -------
Yes, 'template' is disallowed outside of template definition, and the base 
class list is never part of the class definition. The rationale is that '<' 
can't be an operator< in that context.

Anyway, I think Jason would agree to allow it if not pedantic, and a better 
error message would surely be desirable.

I'm keeping this as an enhancement, and I will look into this.

------- Comment #4 From Gabriel Dos Reis 2004-03-15 03:12 -------
Subject: Re:  'template' disambiguator on base class gives a bad error message

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

| Yes, 'template' is disallowed outside of template definition, and the base 
| class list is never part of the class definition. The rationale is that '<' 
| can't be an operator< in that context.
| 
| Anyway, I think Jason would agree to allow it if not pedantic, and a better 
| error message would surely be desirable.

I agree with the better diagnostic part, but I do not for the "not
pedantic" part.

-- Gaby

------- Comment #5 From ron hylton 2004-03-15 17:58 -------
In the following test case I receive an error message saying the use of the 
template disambiguator is required on the base of B::X.

template <class T>
struct A
{
	template <class F>
	class X
	{
	};
};


template <class T>
struct B
{
	template <class F>
	class X : public A<T>::X<F>
	{
	};
};
--:15: error: non-template `X' used as template
--:15: error: (use `A<T>::template X' to indicate that it is a template)
--:17: error: expected `{' before ';' token

Both Comeau C++ 4.3.3 and Intel Windows Compiler 8.0 accept the template 
disambiguator on base classes in all cases I have tried.

--Ron

------- Comment #6 From Giovanni Bajo 2004-03-16 01:41 -------
(In reply to comment #5)

> In the following test case I receive an error message saying the use of the 
> template disambiguator is required on the base of B::X.

This testcase is actually more interesting because it shows a real regression 
(valid code which is not accepted anymore by GCC). The diagnostic suggestion is 
wrong in this context, and the fix is obviously changing GCC to accept the code.

So, we keep both the rejects-valid and the insufficient diagnostic for this PR.

> Both Comeau C++ 4.3.3 and Intel Windows Compiler 8.0 accept the template 
> disambiguator on base classes in all cases I have tried.

For this specific case, the EDG frontend (which is behind both the compiler you 
mentioned) is not a good test because it is very very loosy wrt both 'typename' 
and 'template', for instance you can mostly omit them and the code will still 
compile.

------- Comment #7 From Giovanni Bajo 2004-06-01 01:53 -------
I'm closing this as a dup of PR 15503. The standard does not specify whether 
the code in comment #5 is invalid or not, as explained in PR 15503. This will 
be probably fixed in C++0x, and will be revised by then.

*** This bug has been marked as a duplicate of 15503 ***

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug