Skip to content

Commit 8122b9d

Browse files
Merge pull request #5869 from hannes-steffenhagen-diffblue/fix/constant-propagator-bug
Fix bug in constant propagator
2 parents 99741b3 + e969911 commit 8122b9d

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <assert.h>
2+
3+
void unreachable(void)
4+
{
5+
int x = 0;
6+
assert(x != 0);
7+
}
8+
9+
int main(void)
10+
{
11+
return 0;
12+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
test.c
3+
--constant-propagator
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
VERIFICATION SUCCESSFUL
7+
--
8+
failed to find state
9+
--
10+
This is testing for a previous regression that caused constant propagation to
11+
fail in unreachable code

src/analyses/constant_propagator.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,8 +751,10 @@ void constant_propagator_ait::replace(
751751
{
752752
Forall_goto_program_instructions(it, goto_function.body)
753753
{
754-
// Works because this is a location (but not history) sensitive domain
755-
const constant_propagator_domaint &d = (*this)[it];
754+
auto const current_domain_ptr =
755+
std::dynamic_pointer_cast<const constant_propagator_domaint>(
756+
this->abstract_state_before(it));
757+
const constant_propagator_domaint &d = *current_domain_ptr;
756758

757759
if(d.is_bottom())
758760
continue;

0 commit comments

Comments
 (0)