[clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)
Justin Stitt via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 15 14:08:06 PDT 2025
JustinStitt wrote:
I think there is some confusion in this thread about how to tell the compiler about intentional data loss.
The UX I like the most is something like the following:
```c
void foo() {
int __ob_trap a = -1;
u16 b = a; // trap, semantics we just agreed upon. implicit casts are sketchy
u16 c = (u16)a; // no trap, inform compiler about our intent explicitly, Rust equivalent 'a as u16'
u16 d = (u16 __ob_wrap)a; // no trap, inform compiler about our intent explcitly
u16 e = (u16 __ob_trap)a; // trap, Rust equivalent: 'a.try_into().unwrap()'
}
```
https://github.com/llvm/llvm-project/pull/148914
More information about the cfe-commits
mailing list