This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Incorrect diagnostic for missing operator
- To: GCC Bugs <gcc-bugs at gcc dot gnu dot org>
- Subject: Incorrect diagnostic for missing operator
- From: Michael Eager <eager at mvista dot com>
- Date: Fri, 23 Mar 2001 15:34:48 -0800
- Organization: MontaVista Software, Inc.
The following code has an error, no operator>= defined.
#include <iostream>
#include <string>
class A{
};
int main( int, char **){
A a1, a2;
if( a1 >= a2 )
cout << "1" << endl;
else
cout << "2" << endl;
return 0;
}
With gcc version 2.96 20000731 (Red Hat Linux 7.0)
the diagnostic issued is
$ g++ t.cpp
/usr/include/g++-3/stl_relops.h: In function `bool operator>= (const
_Tp &, const _Tp &) [with _Tp = A]':
t.cpp:8: instantiated from here
/usr/include/g++-3/stl_relops.h:53: no match for `const A & < const A &'
Eliminating the include for <string>, a more reasonable error message
is issued:
$ g++ t.cpp
t.cpp: In function `int main (int, char **)':
t.cpp:11: no match for `A & >= A &'
--
Michael Eager MontaVista Software, Inc. eager@mvista.com
1237 E. Arques Ave., Sunnyvale, CA 94085 408-328-8426