public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15706] New: gcc-3.4.0 gives wrong error message regarding name conflict
@ 2004-05-28 23:34 2boxers at comcast dot net
  2004-05-28 23:35 ` [Bug c++/15706] [3.4 Regression] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: 2boxers at comcast dot net @ 2004-05-28 23:34 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/15706] [3.4 Regression] gcc-3.4.0 gives wrong error message regarding name conflict
  2004-05-28 23:34 [Bug c++/15706] New: gcc-3.4.0 gives wrong error message regarding name conflict 2boxers at comcast dot net
@ 2004-05-28 23:35 ` pinskia at gcc dot gnu dot org
  2004-06-01 15:11 ` bangerth at dealii dot org
  2004-06-01 15:13 ` bangerth at dealii dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-28 23:35 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-28 15:55 -------
Confirmed, here is the reduced source:
namespace f
{
  template <class T> T minus(T, T);
}
using namespace f;
int (*minus)(int,int);
void g()
{
  minus (20, 30);
}

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2004-05-28 15:55:36
               date|                            |
            Summary|gcc-3.4.0 gives wrong error |[3.4 Regression] gcc-3.4.0
                   |message regarding name      |gives wrong error message
                   |conflict                    |regarding name conflict
   Target Milestone|---                         |3.4.1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15706


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/15706] [3.4 Regression] gcc-3.4.0 gives wrong error message regarding name conflict
  2004-05-28 23:34 [Bug c++/15706] New: gcc-3.4.0 gives wrong error message regarding name conflict 2boxers at comcast dot net
  2004-05-28 23:35 ` [Bug c++/15706] [3.4 Regression] " pinskia at gcc dot gnu dot org
@ 2004-06-01 15:11 ` bangerth at dealii dot org
  2004-06-01 15:13 ` bangerth at dealii dot org
  2 siblings, 0 replies; 4+ messages in thread
From: bangerth at dealii dot org @ 2004-06-01 15:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-06-01 15:11 -------
This is a duplicate of some other PR in which I complain that the 
message we get from 3.3, namely 
  g/x> /home/bangerth/bin/gcc-3.3.4-pre/bin/c++ -c x.cc 
  x.cc: In function `void g()': 
  x.cc:9: error: use of `minus' is ambiguous 
  x.cc:6: error:   first declared as `int (*minus)(int, int)' here 
  x.cc:3: error:   also declared as `T f::minus(T, T)' here 
  x.cc:9: error: `minus' undeclared (first use this function) 
  x.cc:9: error: (Each undeclared identifier is reported only once for each  
     function it appears in.) 
is completely bogus since it first complains that there are two 
declarations, then that the name is undeclared. Someone may want to 
go find that other PR. 
 
W. 

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15706


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/15706] [3.4 Regression] gcc-3.4.0 gives wrong error message regarding name conflict
  2004-05-28 23:34 [Bug c++/15706] New: gcc-3.4.0 gives wrong error message regarding name conflict 2boxers at comcast dot net
  2004-05-28 23:35 ` [Bug c++/15706] [3.4 Regression] " pinskia at gcc dot gnu dot org
  2004-06-01 15:11 ` bangerth at dealii dot org
@ 2004-06-01 15:13 ` bangerth at dealii dot org
  2 siblings, 0 replies; 4+ messages in thread
From: bangerth at dealii dot org @ 2004-06-01 15:13 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-06-01 15:13 -------
Found it, PR 100. 

*** This bug has been marked as a duplicate of 100 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15706


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-06-01 15:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-28 23:34 [Bug c++/15706] New: gcc-3.4.0 gives wrong error message regarding name conflict 2boxers at comcast dot net
2004-05-28 23:35 ` [Bug c++/15706] [3.4 Regression] " pinskia at gcc dot gnu dot org
2004-06-01 15:11 ` bangerth at dealii dot org
2004-06-01 15:13 ` bangerth at dealii dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).