Title
Postfix increment/decrement with long bit-field operands
Status
open
Section
7.6.1.6 [expr.post.incr]
Submitter
Mike Miller

Created on 2008-11-11.00:00:00 last changed 195 months ago

Messages

Date: 2020-12-15.00:00:00

Given the following declarations:

    struct S {
        signed long long sll: 3;
    };
    S s = { -1 };

the expressions s.sll-- < 0u and s.sll < 0u have different results. The reason for this is that s.sll-- is an rvalue of type signed long long (7.6.1.6 [expr.post.incr]), which means that the usual arithmetic conversions (Clause 7 [expr] paragraph 10) convert 0u to signed long long and the result is true. s.sll, on the other hand, is a bit-field lvalue, which is promoted (7.3.7 [conv.prom] paragraph 3) to int; both operands of < have the same rank, so s.sll is converted to unsigned int to match the type of 0u and the result is false. This disparity seems undesirable.

History
Date User Action Args
2008-11-11 00:00:00admincreate