Let
int8_t x = 127;
This DR says that while
x++;
invokes UB,
++x;
does not. The resolution was to make the first one valid. The
following test verifies that we don't report any errors in a constexpr
context.
DR 2855
gcc/testsuite/ChangeLog:
* g++.dg/DRs/dr2855.C: New test.
--- /dev/null
+// DR 2855, Undefined behavior in postfix increment
+// { dg-do compile { target c++14 } }
+
+using int8_t = signed char;
+
+constexpr int
+f ()
+{
+ int8_t x = 127;
+ x++;
+ int8_t z = 127;
+ ++z;
+ return x + z;
+}
+
+constexpr int i = f();