Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Codewarrior Windows > A warning from ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 203 of 319
Post > Topic >>

A warning from MS VC7 I'd like to see CodeWarrior adopt - partly :-)

by "Conrad Weyns" <weyns@[EMAIL PROTECTED] > Aug 27, 2004 at 06:28 PM

// A classic test class:
class A
{
   public:
   A(char const*);
};

// A class with a dodgy interface:
class B
{
   public:
   void f(A const&)
   {
   }
   void f(bool)
   {
   }
};

void test()
{
   B b;
   b.f("");
}

b.f("") will call B::f(bool).
Note that declaring A(char const*) explicit makes no difference.
Evidently,
the compiler chooses the build in convertion first anyway.

MS VC7 will output a warning:
   warning C4800: 'char *' : forcing value to bool 'true' or 'false'
(performance warning)

My colleges and I mostly turn a blind eye as soon as we see "(performance
warning)". In this particular case, I'd rather get a more meaningfull
warning e.g: "Are you sure you want us to do this?". "us" because I reckon
there has been more than 1 programmer coding the compiler...
I realize that most of the problem lies with the bool parameter since just
about anything on the face of this earth can be converted to a bool. The
example above is minimalistic. In our real code, we have bool IN-params
all
over the place and many have default values which makes it all the worse.

So, just a wish!
Cheers,
Conrad Weyns
 




 2 Posts in Topic:
A warning from MS VC7 I'd like to see CodeWarrior adopt - partly
"Conrad Weyns"   2004-08-27 18:28:51 
Re: A warning from MS VC7 I'd like to see CodeWarrior adopt - pa
MW Ron <mwron@[EMAIL P  2004-08-27 13:15:45 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 14 11:24:38 CDT 2008.