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

Kees Cook via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 14 15:47:56 PDT 2025


kees wrote:

> FWIW, this _currently_ doesn't compile
> 
> ```c
> $ cat test.c
> void foo(int some) {
>   int __ob_trap big = some;
>   char __ob_wrap byte = big; // is this supposed to wrap or trap? I say wrap -- we're describing how "byte" behaves
> }
> 
> $ clang test.c -foverflow-behavior-types -fsyntax-only
> 
> test.c:3:18: error: cannot assign between incompatible overflow behavior types ('__ob_wrap' and '__ob_trap')
>     3 |   char __ob_wrap byte = big; // is this supposed to wrap or trap? I say wrap -- we're describing how "byte" behaves
>       |                  ^
> 1 error generated.
> ```

Ah, right, forgot that bit, but the rest stands. To replace this example, I'd say, what happens with:

```
int __ob_trap big = runtime_1024;
...
char __ob_wrap byte = (char __ob_wrap)big; // is this supposed to wrap or trap? I say wrap we're casting to match "byte"'s behavior
```

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


More information about the cfe-commits mailing list