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

Justin Stitt via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 24 11:37:56 PDT 2025


================
@@ -9744,6 +9744,16 @@ static void DiagnoseNarrowingInInitList(Sema &S,
 
   case NK_Constant_Narrowing: {
     // A constant value was narrowed.
+
+    // Overflow behavior destination types with a 'wrap' kind can elide
----------------
JustinStitt wrote:

Check out `OverflowBehaviorTypes.rst`'s header regarding `C++ Narrowing Conversions`. The idea is that wrapping types are allowed to abuse wrap-around and intentional truncation/narrowing, we shouldn't warn in these cases.

```c
u32 a;
fun_stuff(&a);


// we are a power user, we've specified behavior for this u8.
u8 __wrap b = a; // potentially abuse truncation/narrowing without littering (u8) casts in places.
```

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


More information about the cfe-commits mailing list