bug 4/ bool
Mark Mitchell
mmitchell@usa.net
Mon Dec 22 10:35:00 GMT 1997
>From the standard:
19) Using a bool value in ways described by this International Stan-
dard as ``undefined,'' such as by examining the value of an
uninitial- ized automatic variable, might cause it to behave as
if is neither true nor false.
Breymann> ***** test case **** #include<iostream.h>
Breymann> int main() { bool logicalValue; if(logicalValue) { cout
Breymann> << "true\n"; logicalValue = !logicalValue; // negation
Breymann> if(logicalValue) cout << "Error! logicalValue must be
Breymann> false here!\n"; } else cout << "logigalValue by accident
Breymann> initialized with false\n"; }
Breymann> The program shows the error message, i.e. negation does
Breymann> not work.
Breymann> Reason: wrong initialization of bool objects, should be
Breymann> undefined, but either true or false
--
Mark Mitchell mmitchell@usa.net
Stanford University http://www.stanford.edu
More information about the Gcc-bugs
mailing list