When the standard says "no diagnostic required", that means that the compiler does not have to produce an error or warning about the invalid code, but that the code's behavior is still undefined according to the standard and so it won't necessarily have predictable results. This is intended to make things easier on compiler-writers so that they are not obligated to detect relatively rare or particularly troublesome-to-detect sorts of programmer errors.
However, when a rule with "no diagnostic required" is violated, the compiler is not prohibited from detecting the invalid code and producing an error as a courtesy to the user. So in the example given, gcc is producing a courtesy diagnostic for one particular sort of invalid code, and Comeau is producing a courtesy diagnostic for a similar sort of invalid code. But neither diagnostic is required, so in neither case is the other compiler in violation of the standard by not producing an error message. The behavior of the code remains undefined in any case.
Several relevant standards quotations regarding class names and template names:
3.4/1
The name lookup rules apply uniformly
to all names (including typedef-names
(7.1.3), namespace-names (7.3) and
class-names (9.1)) wherever the
grammar allows such names in the
context discussed by a particular
rule. Name lookup associates the use
of a name with a declaration (3.1) of
that name. Name lookup shall find an
unambiguous declaration for the name
(see 10.2). [...]
7.1.3/3
In a given scope, a typedef specifier
shall not be used to redefine the name
of any type declared in that scope to
refer to a different type. [Example:
class complex { /* ... */ };
typedef int complex; // error: redefinition
—end example] Similarly, in a given
scope, a class or enumeration shall
not be declared with the same name as
a typedef-name that is declared in
that scope and refers to a type other
than the class or enumeration itself. [...]
9.1/2
A class definition introduces the
class name into the scope where it is
defined and hides any class, object,
function, or other declaration of that
name in an enclosing scope (3.3). If a
class name is declared in a scope
where an object, function, or
enumerator of the same name is also
declared, then when both declarations
are in scope, the class can be
referred to only using an
elaborated-type-specifier (3.4.4).
14/5
A class template shall not have the
same name as any other template,
class, function, object, enumeration,
enumerator, namespace, or type in the
same scope (3.3), except as specified
in (14.5.4). Except that a function
template can be overloaded either by
(non-template) functions with the same
name or by other function templates
with the same name (14.8.3), a
template name declared in namespace
scope or in class scope shall be
unique in that scope.
14.5.4/1
A primary class template declaration
is one in which the class template
name is an identifier. A template
declaration in which the class
template name is a template-id, is a
partial specialization of the class
template named in the template-id. A
partial specialization of a class
template provides an alternative
definition of the template that is
used instead of the primary definition
when the arguments in a specialization
match those given in the partial
specialization (14.5.4.1). [...]
So, in summary:
typedefs cannot change the meaning of an existing type
class names can conflict with certain sorts of names, but not other class names
template class names do not include the template parameter, and cannot conflict with anything, even things that normal class names are allowed to conflict with
- template specializations are considered to have the same template-id (name) as their corresponding generalized template, but they are (obviously) not the same type.
So there's a conflict in both directions here. The template name is not allowed to conflict with anything, and the typedef is not allowed to change A from a template class type to a specialization of a template class type.