This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Input stream with
- From: Andre-Marcel Hellmund <hellmund at fzi dot de>
- To: <gcc-help at gcc dot gnu dot org>, <libstdc++ at gcc dot gnu dot org>
- Date: Thu, 19 Mar 2015 22:43:43 +0100
- Subject: Input stream with
- Authentication-results: sourceware.org; auth=none
Hi,
I am not sure which of the two lists is the appropriate one, so sorry
for using both :-)
Given the following simple test program:
#include <cstdint>
#include <iostream>
#include <sstream>
int main () {
std::stringstream ss;
ss << "0xFFFFFFFF";
int32_t val = 0;
ss >> std::hex >> val;
std::cout << std::hex << val << std::dec << " - " << ss.fail() <<
std::endl;
return 0;
}
The output of the program is: 7fffffff - 1
In the first instance, I was somehow expecting the value of 'val' to be
-1, so I was wondering which part of the C++ standard defines those
conversion rules and hence explains why my expectation was totally
wrong. Could someone please give me a hint?
Thank and Best Regards,
Andi