Shifting out of range (1 << 31) as currently defined (if shift has defined value when interpreted as unsigned, you get the value as signed, you can dhigt into but not past the sign, shifting past sign bit is UB), 1<<31 was defined and still is (as of Howard's paper), 2<<31 was UB and still is, WG14 is currently considering whether to adopt Howard's paper which made this. Should we take it back to undefined to do 1<<31?
SS F N A SA
2 7 5 1 1
On Fri, Mar 16, 2018 at 2:04 PM, Arthur O'Dwyer <email@example.com> wrote:P0907r1 proposes this addition relative to the WD:> If overflow caused by an operation which would require representing an integer which cannot be represented by the type, the behavior is undefined.However, it simultaneously proposes these deletions relative to the WD:> [Note: Operators can be regrouped according to the usual mathematical rules only where the operators really are associative or commutative ...and> an operation that would have undefined behavior as specified in Clause 4 through 19 of this document [Note: including, for example,
signed integer overflow,certain pointer arithmetic, division by zero, or certain shift operations —end note]The removals are all non-normative, but they seem to be aimed at eliminating references to "signed overflow is UB", even though signed overflow is still UB. Was there a sense in the room that we wanted to downplay the importance of teaching signed UB in C++, but not actually eliminate the UB itself? Or what's the point of re-wording these existing notes?There was extensive discussion of this note, what to add / remove, etc, and no direction as to where to go. I'll ask EWG today.Also, separately and less importantly, I'd love to hear someone's rationale for making (1<<31) UB in C++2a when it's IDB in C++17. The straw poll result in P0907r1 sounds unambiguous, but I don't understand what rationale could exist for taking this construct from IDB into UB. Is the assumption that people haven't yet had a chance to write any programs whose correctness depends on the value of (1<<31), so if we change it back to UB fast enough, nobody will notice?The notes should help clarify RIchard's rationale for proposing this.–ArthurOn Fri, Mar 16, 2018 at 8:56 AM, JF Bastien <firstname.lastname@example.org> wrote:______________________________Hello EWG,SG6 and SG12 discussed wg21.link/P0907r0 Signed Integers are Two’s Complement and provided extensive feedback.I've attached an updated paper listing polls and addressing most feedback (except some wording fiddle) to the EWG wiki for this afternoon's discussion:Thanks,JF _________________
ub mailing list