Last active
January 4, 2016 19:51
-
-
Save jonathan-beard/25c74f8e318688243d30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <iomanip> | |
#include <cstdlib> | |
/** try with -O0 then -O3 **/ | |
struct foo | |
{ | |
/** | |
* remember, this should be undetermined.... | |
* never leave a class var like this | |
*/ | |
bool x; | |
}; | |
int | |
main( int argc, char **argv ) | |
{ | |
foo f; | |
/** | |
* compiler seems to optimize this to f.x always true | |
* unless we add default initialization explicitely for | |
* x or else to set, but you shouldn't rely on this... | |
* in fact, NEVER rely on this. | |
*/ | |
if( argc == 2 ) | |
{ | |
f.x = true; | |
} | |
std::cout << std::boolalpha << f.x << "\n"; | |
return( EXIT_SUCCESS ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment