bug report
Wim Lavrijsen
wlav@mail.cern.ch
Fri Mar 31 05:26:00 GMT 2000
To whom this may concern,
$uname -a
Linux atlas22 2.0.35 #1 Wed Nov 25 15:50:56 CET 1998 i686 unknown
$g++ --version
2.95.2
$more problem.cxx
#include <assert.h>
template< class TPtr >
class Ptr {
public:
Ptr( TPtr* ptr = 0 ) : _ptr( ptr ) {}
operator bool() const;
private:
TPtr* _ptr;
};
template< class TPtr >
inline Ptr< TPtr >::operator bool() const {
return _ptr;
}
void func( const Ptr< int >& r ) {
assert( static_cast< bool >( r ) );
}
int main() {
int i = 1;
Ptr< int > pi( &i );
func( pi );
return 0;
}
$g++ problem.cxx
problem.cxx: In function `void func(const Ptr<int> &)':
problem.cxx:18: static_cast from `const Ptr<int>' to `bool'
Please note that the problem only occurs if:
1) the Ptr class is a template,
2) the function takes a reference and
3) the reference is passed as a function argument (taking a
reference in main and then asserting works fine)
Best regards,
Wim Lavrijsen
More information about the Gcc-bugs
mailing list