This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
gcc-3.4.0 incorrect error message
- From: "2boxers" <2boxers at comcast dot net>
- To: <gcc at gnu dot org>
- Date: Thu, 27 May 2004 18:04:35 -0400
- Subject: gcc-3.4.0 incorrect error message
Considering the following code:
// pointer to functions
#include <iostream>
using namespace std;
int addition (int a, int b)
{ return (a+b); }
int subtraction (int a, int b)
{ return (a-b); }
int (*minus)(int,int) = subtraction;
int operation (int x, int y, int (*functocall)(int,int))
{
int g;
g = (*functocall)(x,y);
return (g);
}
int main ()
{
int m,n;
m = operation (7, 5, addition);
n = operation (20, m, minus);
cout <<n;
return 0;
}
While there is nothing wrong with the program code itself, there is a name
conflict with the object "minus".
gcc-3.2.2 kindly points this out with this message:
pointer4.cpp: In function `int main()':
pointer4.cpp:24: use of `minus' is ambiguous
pointer4.cpp:11: first declared as `int (*minus)(int, int)' here
/usr/include/c++/3.2.2/bits/stl_function.h:134: also declared as `
template<class _Tp> struct std::minus' here
gcc-3.4.0, however, erroneuosly states that minus has been undeclared:
pointer4.cpp: In function `int main()':
pointer4.cpp:24: error: `minus' undeclared (first use this function)
pointer4.cpp:24: error: (Each undeclared identifier is reported only once
for each function it appears in.)
Clearly the use of using namespace std; is not ideal form, however, it is
the message from gcc-3.4.0 that concerns me.
Thank you,
Charles Wilkins