This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Bug report - Optimisation problem


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]