This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
bug 4/ bool
- To: Breymann at t-online dot de (Breymann)
- Subject: bug 4/ bool
- From: Mark Mitchell <mmitchell at usa dot net>
- Date: Mon, 22 Dec 1997 10:37:21 GMT
- Cc: egcs-bugs at cygnus dot com
- References: <m0xk9z6-0003UrC@fwd06.btx.dtag.de>
- Reply-To: mmitchell at usa dot net
>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