3 ms·
Doh! Good catch, comment updated. =[ Maybe we do need Clang-for-comments as well as Clang-for-C++ code.... ;]
by chandlerc 15y ago
Doh! Good catch, comment updated. =[ Maybe we do need Clang-for-comments as well as Clang-for-C++ code.... ;]
- nikki9696 15y agoAnd the error says it's an int, but it's declared long. Am I missing something about long in C++ not being 64 bits?
- chandlerc 15y agoThat's the whole point. =] This is a surprising aspect of C++: the shift expression doesn't have the type of the declared variable. The integer literals we are shifting are of 'int' type, and the shift occurs at that type (based on the usual arithmetic conversions). There is stack overflow question with explanations and a good blog post here about it: http://stackoverflow.com/questions/836544/usual-arithmetic-conversion-a-better-set-of-rules http://stackoverflow.com/questions/836544/usual-arithmetic-c... http://blogs.msdn.com/b/oldnewthing/archive/2004/03/10/87247.aspx http://blogs.msdn.com/b/oldnewthing/archive/2004/03/10/87247... Also, you can look through the C++98 standard to understand all the details. Relevant sections are [expr]p9 and [expr.shift].
- DarkShikari 15y agolong is 32-bit on x86_32 Linux, 64-bit on x86_64 Linux, and 32-bit on x86_64 Windows.
- DerekL 15y agoThe left operand is an int, so the result of the shift expression is an int. The fact that the shift expression is used to initialize a long is not relevant.
- lukesandberg 15y agoin that case you should checkout this paper: "iComment: bugs or bad comments" (http://portal.acm.org/citation.cfm?id=1294276 http://portal.acm.org/citation.cfm?id=1294276 sorry couldnt find an open pdf)