This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Bug report - Optimisation problem
- To: gcc-bugs <gcc-bugs at gcc dot gnu dot org>
- Subject: Bug report - Optimisation problem
- From: Philippe Bouchard <philippeb at corel dot com>
- Date: Wed, 18 Oct 2000 18:01:12 +0000
Version:
Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.2/specs
gcc version 2.95.2 20000220 (Debian GNU/Linux)
Program:
#include <iostream>
template <typename T> struct A
{
operator T const & () const
{
cout << __PRETTY_FUNCTION__ << endl;
}
};
ostream & operator << (ostream & o, A<bool> const & s)
{
//cout << __PRETTY_FUNCTION__ << endl;
return o << (static_cast<bool const &>(s) ? "true" : "false");
}
void main()
{
A<bool> a = A<bool>();
cout << a << endl;
}
Reports:
cast.cpp: In function `class ostream & operator <<(ostream &, const
A<bool> &)':cast.cpp:14: `const struct A<bool>' used where a `bool' was
expected
I know this is an optimizer problem because if you uncomment the "cout"
line in the "operator <<" function, everything will work fine.
Thank you.
begin:vcard
n:Bouchard;Philippe
x-mozilla-html:FALSE
org:Corel Linux
adr:;;;;;;
version:2.1
email;internet:philippeb@corel.com
title:Software Engineer
x-mozilla-cpt:;0
fn:Philippe Bouchard
end:vcard