This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/15706] New: gcc-3.4.0 gives wrong error message regarding name conflict
- From: "2boxers at comcast dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 May 2004 15:44:59 -0000
- Subject: [Bug c++/15706] New: gcc-3.4.0 gives wrong error message regarding name conflict
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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
--
Summary: gcc-3.4.0 gives wrong error message regarding name
conflict
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: 2boxers at comcast dot net
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15706