egcs 1.1b (2.91.57), g++ -pedantic issues possibly extraneous error
E. Jay Berkenbilt
ejb@ql.org
Mon Oct 26 13:38:00 GMT 1998
I am using egcs 1.1b as compiled by someone else and uploaded to
contrib.redhat.com. egcs --version, gcc --version, g++ --version say
egcs-2.91.57.
The following program:
-----------------
#include <iostream.h>
#include <vector>
struct A
{
A(int a) : a(a) {};
int a;
};
template <class T>
static int count_a0(vector<T*> const& v)
{
int result = 0;
vector<T*>::const_iterator iter;
for (iter = v.begin(); iter != v.end(); ++iter)
{
if ((*iter)->a == 0)
{
++result;
}
}
return result;
}
int main()
{
vector<A*> v;
v.push_back(new A(0));
v.push_back(new A(1));
v.push_back(new A(2));
v.push_back(new A(1));
v.push_back(new A(0));
cout << count_a0(v) << endl;
}
-----------------
Compiles and runs properly without -pedantic. With -pedantic, you get
a.cc: In function `int count_a0(const class vector<T *,__default_alloc_template<true,0> > &)':
a.cc:14: parse error before `;'
a.cc: In function `int count_a0<A>(const class vector<A *,__default_alloc_template<true,0> > &)':
a.cc:34: instantiated from here
a.cc:15: `iter' undeclared (first use this function)
a.cc:15: (Each undeclared identifier is reported only once
a.cc:15: for each function it appears in.)
a.cc:15: confused by earlier errors, bailing out
gcc 2.7.2.3 accepted this with -pedantic. I don't believe there is
anything in the ANSI spec that would warrant an error here.
--
E. Jay Berkenbilt (ejb@ql.org) | http://www.ql.org/q/
More information about the Gcc-bugs
mailing list