Skip to content

Commit b1e4ddb

Browse files
committed
[analyzer][WIP] Demonstrate BoolAssignment crash
This commit adds a testcase to `bool-assignment.c` which currently makes `assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!")` fail at line 179 of `APSInt.h`. I found this assert as I tried to start investigating performance questions on a preprocessed version of `unicode.c` from the ruby source code.
1 parent f5815b9 commit b1e4ddb

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

clang/test/Analysis/bool-assignment.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,20 @@ void test_tainted_Boolean() {
111111
scanf("%d", &n);
112112
Boolean copy = n; // expected-warning {{Might assign a tainted non-Boolean value}}
113113
}
114+
115+
116+
// The following fragment is taken from unicode.c in the ruby source code and
117+
// it currently triggers a crash.
118+
119+
typedef __typeof(sizeof(int)) size_t;
120+
struct rbimpl_size_mul_overflow_tag {
121+
_Bool left;
122+
size_t right;
123+
};
124+
struct rbimpl_size_mul_overflow_tag
125+
rbimpl_size_mul_overflow(size_t x, size_t y)
126+
{
127+
struct rbimpl_size_mul_overflow_tag ret = { 0, 0, };
128+
ret.left = __builtin_mul_overflow(x, y, &ret.right);
129+
return ret;
130+
}

0 commit comments

Comments
 (0)