This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Bug, in the library, I think
- To: libstdc++ at gcc dot gnu dot org
- Subject: Bug, in the library, I think
- From: Ken Yarnall <pettice dot yarnall at verizon dot net>
- Date: Thu, 27 Sep 2001 19:42:37 -0400
- Organization: Lebanon Valley College
- References: <20010927184601.A8239@disaster.jaj.com>
- Reply-To: yarnall at lvc dot edu
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