Bug, in the library, I think
Ken Yarnall
pettice.yarnall@verizon.net
Thu Sep 27 16:45:00 GMT 2001
A student of mine encountered a bug, using gcc 3.0.1. Her code looks
more or less like
class error {};
#include <iostream>
This causes parsing errors in bits/codecvt.h. The problem is that
codecvt_base contains an enum (result) which lists "error" as one of its
members. Code in the indirect derived class codecvt refers to "error"
without qualification.
This normally isn't a problem, given C++ lookup rules. However, the
intervening base class is a template, so essentially, "error" is a name
declared in a templated base class (and hence is a dependent name).
When the compiler sees "error" in codecvt's member functions, it chooses
the global name, generating the parse error.
If I read Stroustrup and the standard correctly, the compiler is
actually doing the right thing (I was surprised by this). The solution
seems to be to qualify references to codecvt_base::error. The advice
in Stroustrup's appendix on technicalities seems to be good --- reduce
or eliminate the use of unqualified names in the presence of templates.
I'm glad to supply more detail if this is insufficient.
Cheers,
Ken
--
Ken Yarnall
Dept. of Mathematical Sciences Lebanon Valley College
Assoc. Professor of Math and CS (717)867-6085 yarnall@lvc.edu
More information about the Libstdc++
mailing list