This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Template problem (from `iterator_traits')


> I report the following problem but I have no idea whether it is bug in
> the code or in the compilers;

It is a bug in the code.

>   std::iterator_traits<X::I>::value_type v = 10;
[...]
> I would expect the compiler look up `value_type' etc. in enclosing
> scopes, but KCC 3.3e (on HP-UX 10.20) gives:

No. This is a qualified access. [class.qual] says

>> If the nested­name­specifier of a qualified­id nominates a class,
>> the name specified after the nested­name­specifier is looked up in
>> the scope of the class (10.2), except for the cases listed
>> below. The name shall represent one or more members of that class
>> or of one of its base classes (clause 10).

No word about enclosing scopes. Since value_type is not a member X::I,
the program is ill-formed.

The rule you are proposing means that

void printf(char*,...);
class X{
};

int main()
{
  X::printf("Hello, world\n");
}

would be well-formed. In standard C++, it is not.

Regards,
Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]