Alternate title: "Another great candidate for a warning message"
So I was testing a program and noticed some really weird behavior. It was acting as if some boolean values had been set to 'true', though I was certain that they had not been. Incredulous, I decided to print them out. To my suprise, the output was something like:
96
34
71
I started to panic - surely this was a sign of major stack corruption! Just as I was about to fire up the debugger I decided to recheck the class, just for good measure. Then I spotted it:
Ack - I was initializing the member with itself!Code:struct foo { foo( bool enable ) : enabled( enabled ) { } // ... };
I wonder why gcc didn't issue a warning, though? I mean, when would you *ever* need to do such a thing, anyway? Let's see...never! I've got just about every warning turned on, too, even -Wunused (which should have been triggered, I would think).



LinkBack URL
About LinkBacks



CornedBee