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 4/ bool



>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



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