This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Incorrect diagnostic for missing operator


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]