Repository navigation
fix: do correct indexing of padding fields - #1387
Conversation
|
I think this is completely independent of #1386 |
|
ah, I ran into the typecheck error first so that's what I reported, but this bug like the previous PR is an unsoundness bug. adding a test case about that now (which covers arrays, which I should have added tests about in the first place). |
| return i; | ||
| ++seen; | ||
| } | ||
| UNREACHABLE(); |
There was a problem hiding this comment.
I think this is UB for an out-of-bounds idx. Also I think the logic could be simplified. Maybe something like
unsigned AggregateType::paddedIndex(unsigned idx) const {
assert(idx < elements - numPaddingsConst());
for (unsigned i = 0; ; ++i) {
if (!is_padding[i] && idx-- == 0)
return i;
}
}There was a problem hiding this comment.
in alive2 UNREACHABLE() becomes __builtin_unreachable() which turns into a trap, so the effect would be the same, assuming your assert and my UNREACHABLE() are equisatisfiable
There was a problem hiding this comment.
From clang docs:
The
__builtin_unreachable()builtin has completely undefined behavior.
There was a problem hiding this comment.
yes of course. but it turns into a trap in practice.
there's nothing wrong with the 2 new test cases here, but without this PR, running alive-tv on them gives:
ERROR: program doesn't type check!