================
@@ -215,3 +215,12 @@ void test_add_overflow_s111(void) {
clang_analyzer_warnIfReached(); // no-warning: we always get an overflow,
thus choose the other branch
}
+
+void test_add_overflow_scratch_type_too_narrow(void) {
+ int a = 32767, b = 32767;
+ signed char res;
+
+ // This is a false negative. 32767 + 32767 == 65534, which does not
+ // fit in a signed char ([-128, 127]), so this should evaluate to TRUE.
+ clang_analyzer_eval(__builtin_add_overflow(a, b, &res)); // expected-warning
{{TRUE}}
----------------
steakhal wrote:
```suggestion
// 32767 + 32767 == 65534, which does not fit in a signed char ([-128, 127]),
so this evaluates to TRUE.
clang_analyzer_eval(__builtin_add_overflow(a, b, &res)); // expected-warning
{{TRUE}}
```
https://github.com/llvm/llvm-project/pull/214553
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits