[Lldb-commits] [clang] [lldb] [Clang] Introduce OverflowBehaviorType for fine-grained overflow control (PR #148914)

Justin Stitt via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 30 13:09:43 PDT 2025


JustinStitt wrote:

@rjmccall 
> You linked me to this post promising a detailed discussion of the model, but I can't quite piece out what overflow model you're actually proposing for the compliant mode. :)

Sorry, I tried to fit all the information in my post without writing a book. To summarize, the model I propose for "compliant" mode best matches Model 2 from your comment on the RFC.

The usual arithmetic conversions take place normally and we bubble up any obt qualifiers through implicit casts. Most of the time we can catch trivial overflow with int-or-greater types like

```c
int __ob_trap a = INT_MAX;
(a+1); // trap!
```

but for less-than-int cases we can instrument the assignment or storage to trap on truncation:

```c
u8 __ob_trap a = 255;
u8 = a + 1; // trap! (on assignment truncation)

// (a+1) is brought up to an `__ob_trap int` as per usual arithmetic conversions.
// that doesn't fit into u8 without data loss. so trap.
```

https://github.com/llvm/llvm-project/pull/148914


More information about the lldb-commits mailing list