This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
bug report
- To: egcs-bugs at egcs dot cygnus dot com, gcc-bugs at gcc dot gnu dot org, ASIS dot Support at cern dot ch
- Subject: bug report
- From: Wim Lavrijsen <wlav at mail dot cern dot ch>
- Date: Fri, 31 Mar 2000 15:26:15 +0200 (CEST)
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