------- Comment #3 from redi at gcc dot gnu dot org 2009-10-07 09:48 ------- (In reply to comment #2) > Thanks for the fast reply! I had tried compilation with VC++ 2008 and there it > worked, so I thought it would be valid.
You should be wary of using VC++ to determine if code is valid, it's not often right! > Maybe a more expressive error message could help. In this shortened example > the > error message is ... well... okay, but in my reallife project I get this as a > first error, which is totally misleading (and lead me into thinking this is a > compiler bug): > > C:\Programme\C++\Projects\FreeFileSync\algorithm.cpp|565|error: no match for > 'operator<' in 'dbLeft->DetectChanges::detectFileChange [with > FreeFileSync::SelectedSide side = side, bool respectFiltering = true] < > (FreeFileSync::SelectedSide)0u'| > C:\Programme\C++\wxWidgets\include\wx\string.h|1572|note: candidates are: bool > operator<(const wxString&, const wxString&)| > C:\Programme\C++\wxWidgets\include\wx\string.h|1574|note: bool > operator<(const wxString&, const wxChar*)| > C:\Programme\C++\wxWidgets\include\wx\string.h|1576|note: bool > operator<(const wxChar*, const wxString&)| > C:\Programme\C++\wxWidgets\include\wx\longlong.h|1040|note: > bool operator<(long int, const wxLongLong&)| > C:\Programme\C++\wxWidgets\include\wx\longlong.h|1053|note: > bool operator<(long unsigned int, const wxULongLong&)| > Although it may be confusing, the message is technically correct, due to the complicated parsing rules of C++. no match for 'operator<' in 'dbLeft->DetectChanges::detectFileChange [...] < (FreeFileSync::SelectedSide)0u' says that the expression is being interpreted as 'x < y' where x is the member 'detectFileChange' and y is an integer constant. There is no appropriate operator< available so it lists the visible overloads of operator< The rules of C++ specifically say that the compiler must interpret it like that, see 14.3 [temp.names] paragraph 4. The way to resolve it is to say you are calling a template member function, by inserting the keyword 'template' before the template-id, as I showed. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41614