Re: Very odd Comeau C++ behavior

Just a follow up that in addition to the work around previously sent below, there is now a patch that fixes the underlying problem. Holler if you need a revised compiler. - Greg At 08:40 PM 1/26/2004 +0200, Peter Dimov wrote:
While implementing operator== for boost::mem_fn, I found that the following program, which I expected to print '1' six times, mysteriously outputs 1 0 1 1 0 1 under Comeau C++, causing all mem_fn equality tests to fail:
#include <iostream>
struct X { int mf0_1() { return 0; } int mf0_2() { return 0; } };
struct mf0 { typedef int (X::*F) (); F f_;
explicit mf0(F f): f_(f) {}
bool operator==(mf0 const & rhs) const { return f_ == rhs.f_;
Thanks for the report, it appears you've uncovered a problem. It's being looked into further. For now, this should work: return f_ == rhs.f_ ? true : false;
}
bool operator!=(mf0 const & rhs) const { return f_ != rhs.f_;
As well as here: return f_ != rhs.f_ ? true : false;
} };
int main() { std::cout << ( &X::mf0_1 == &X::mf0_1 ) << std::endl; std::cout << ( mf0(&X::mf0_1) == mf0(&X::mf0_1) ) << std::endl; std::cout << ( mf0(&X::mf0_1).f_ == mf0(&X::mf0_1).f_ ) << std::endl;
std::cout << "--\n";
std::cout << ( &X::mf0_1 != &X::mf0_2 ) << std::endl; std::cout << ( mf0(&X::mf0_1) != mf0(&X::mf0_2) ) << std::endl; std::cout << ( mf0(&X::mf0_1).f_ != mf0(&X::mf0_2).f_ ) << std::endl; }
Output:
C:\Documents and Settings\pdimov\My Documents\Projects\testbed>como testbed.cpp Comeau C/C++ 4.3.0.1 (Aug 21 2002 15:45:32) for MS_WINDOWS_x86 Copyright 1988-2002 Comeau Computing. All rights reserved. MODE:strict errors C++
C:\Documents and Settings\pdimov\My Documents\Projects\testbed>aout.exe 1 0 1 -- 1 0 1
Is this a known issue with Comeau C++ 4.3? Or is there something wrong with the code?
------- Comeau C/C++ 4.3.3: Offering core language support for C++03 Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90. Comeau C/C++ with Dinkumware's Libraries. Have you tried it? comeau@comeaucomputing.com http://www.comeaucomputing.com
participants (1)
-
Comeau Computing