[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 12:04:37 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:

> Why is that a reasonable assumption?

`__wrap` is opt-in and is designed to behave differently at bit boundaries when overflowing them or when taking on a value larger than available storage space.

> This change in behavior means that an error by the developer is now silently ignored. Now an unintentional narrowing of the data is silently ignored.

There is no change in behavior to any developer, this is a new featureset entirely. We aren't changing anything under anyone's feet (and if we are, that is a bug/oversight in my code). This feature is for power users who have clearly expressed their intent in utilizing funky wrap-around arithmetic.

But yes, it is possible to write bad code, even when using OBTs.

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


More information about the cfe-commits mailing list