Issue 183760
Summary Compile-time pre-inc/post-inc do not honor wrapping types
Labels clang:frontend, constexpr
Assignees
Reporter tbaederr
    See https://godbolt.org/z/fnd7KG3vM

```c++
#define __wrap __attribute__((overflow_behavior(wrap)))
#define __no_trap __attribute__((overflow_behavior(trap)))

typedef int __ob_wrap wrap_int;
typedef int __ob_trap no_trap_int;

constexpr wrap_int add(wrap_int a, wrap_int b) {
  return a + b;
}

constexpr wrap_int preinc(wrap_int a) {
  ++a;
  return a;
}

constexpr wrap_int postinc(wrap_int a) {
  a++;
  return a;
}

constexpr wrap_int max = 2147483647;
constexpr wrap_int _one_ = 1;
static_assert(add(max, one) == -2147483648, "constexpr wrapping failed");
static_assert(max+1 == -2147483648);
static_assert(preinc(max) == -2147483648);
static_assert(postinc(max) == -2147483648);
```

Since the first two static asserts work, I'd expect the last two to also work.

CC @JustinStitt 
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to