Created
April 27, 2013 20:42
-
-
Save Jorge-C/5474637 to your computer and use it in GitHub Desktop.
Weird behaviour
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 <climits> | |
const int toEnd = INT_MAX; |
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 <foo.h> | |
#include <climits> | |
int _end = toEnd; // Adding const makes it behave nicely | |
int mx = INT_MAX; | |
int main() { | |
std::cout << "INT_MAX " << mx << std::endl; | |
std::cout << "_end " << _end << std::endl; | |
std::cout << "toEnd " << toEnd << std::endl; | |
/* Output (gcc 4.6.3, x86_64) | |
INT_MAX 2147483647 | |
_end 0 // !! | |
toEnd 2147483647 | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment