This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Template problem (from `iterator_traits')
- To: lat at iki dot fi
- Subject: Re: Template problem (from `iterator_traits')
- From: Martin von Loewis <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Sat, 7 Nov 1998 12:48:24 +0100
- CC: egcs-bugs at cygnus dot com
- References: <Pine.LNX.3.96.981106171921.25468s-100000@pcatlas112.cern.ch>
> 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 nestednamespecifier of a qualifiedid nominates a class,
>> the name specified after the nestednamespecifier 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