Skip to content

Instantly share code, notes, and snippets.

@Jorge-C
Created April 27, 2013 20:42
Show Gist options
  • Save Jorge-C/5474637 to your computer and use it in GitHub Desktop.
Save Jorge-C/5474637 to your computer and use it in GitHub Desktop.
Weird behaviour
#include <climits>
const int toEnd = INT_MAX;
#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