Created on 2006-10-23.00:00:00 last changed 178 months ago
[Voted into WP at October, 2009 meeting.]
Proposed Resolution (July, 2009):
Change 15.2 [cpp.cond] paragraph 4 as follows:
...and then each preprocessing token is converted into a token. The resulting tokens comprise the controlling constant expression which is evaluated according to the rules of 7.7 [expr.const] using arithmetic that has at least the ranges specified in 17.3 [support.limits], except that. For the purposes of this token conversion and evaluation all signed and unsigned integer types act as if they have the same representation as, respectively, intmax_t or uintmax_t (_N3035_.18.4.2 [stdinth])[Footnote: Thus on an implementation where std::numeric_limits<int>::max() is 0x7FFF and std::numeric_limits<unsigned int>::max() is 0xFFFF, the integer literal 0x8000 is signed and positive within a #if expression even though it is unsigned in translation phase 7 (5.2 [lex.phases]). —end footnote]. This includes interpreting character literals...
The description of preprocessing expressions in 15.2 [cpp.cond] paragraph 4 says,
The resulting tokens comprise the controlling constant expression which is evaluated according to the rules of 5.19 using arithmetic that has at least the ranges specified in 17.3 [support.limits], except that all signed and unsigned integer types act as if they have the same representation as, respectively, intmax_t or uintmax_t (18.3.2).
However, this does not address the type implicitly assigned to integral literals. For example, in an implementation where int is 32 bits and long long is 64 bits, is a literal like 0xffffffff signed or unsigned? WG14 adopted DR 265 to deal with this issue in the essentially-identical wording in C99; we should probably follow suit for C++.
History | |||
---|---|---|---|
Date | User | Action | Args |
2010-03-29 00:00:00 | admin | set | status: dr -> cd2 |
2009-11-08 00:00:00 | admin | set | messages: + msg2479 |
2009-11-08 00:00:00 | admin | set | status: ready -> dr |
2009-08-03 00:00:00 | admin | set | status: review -> ready |
2008-02-03 00:00:00 | admin | set | messages: + msg1569 |
2008-02-03 00:00:00 | admin | set | status: drafting -> review |
2007-05-06 00:00:00 | admin | set | status: open -> drafting |
2006-10-23 00:00:00 | admin | create |