On Sunday, September 04, 2011 22:59:21 Timon Gehr wrote: > static assert(0xF234_5678_9ABC_5A5AUL == 17452669531959614042UL); > > auto a = 0xF234_5678_9ABC_5A5AL; // ok, type is ulong > auto b = 17452669531959614042L; // error, signed integer overflow > > But p33. in TDPL states: > "To write a hexadecimal integral literal, use the prefix 0x or 0X > followed by a sequence of the letters 0-9, a-f, A-F, or _. [...] All of > these literals can be suffixed similarly to the decimal constants, and > the rules governing their types are identical to those for decimal > literals." > > Is this a compiler bug or an error in TDPL?
It sounds like the compiler assumes that a hexadecimal literal is unsigned and that a decimal literal is signed - which is what I would have expected it to do. TDPL should probably be changed. But maybe Walter or Andrei has a different opinion on that. - Jonathan M Davis
