Undefined pointer arithmetic in constant expressions
7.7 [expr.const]
Jens Maurer

Created on 2011-05-07.00:00:00 last changed 83 months ago


Date: 2012-02-15.00:00:00

[Voted into the WP at the February, 2012 meeting; moved to DR at the October, 2012 meeting.]

Date: 2011-08-15.00:00:00

Proposed resolution (August, 2011):

Change 7.7 [expr.const] paragraph 2 as follows:

  • ...

  • a result that is not mathematically defined or not in the range of representable values for its type;

  • an operation that would have undefined behavior [Note: including, for example, signed integer overflow (Clause Clause 7 [expr]), certain pointer arithmetic (7.6.6 [expr.add]), division by zero (7.6.5 [expr.mul]), or certain shift operations (7.6.7 [expr.shift]) —end note];

  • ...

  • a subtraction (7.6.6 [expr.add]) where both operands are pointers;

  • ...

Date: 2012-09-24.00:00:00

The requirements for constant expressions do not currently, but should, exclude expressions that have undefined behavior, such as pointer arithmetic when the pointers do not point to elements of the same array.

Date User Action Args
2014-03-03 00:00:00adminsetstatus: drwp -> cd3
2012-11-03 00:00:00adminsetstatus: dr -> drwp
2012-09-24 00:00:00adminsetmessages: + msg4002
2012-09-24 00:00:00adminsetmessages: + msg4001
2012-09-24 00:00:00adminsetstatus: review -> dr
2012-02-27 00:00:00adminsetstatus: ready -> review
2011-05-07 00:00:00admincreate