Commit 12ecb3fe authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz

twagraph: fix purge_dead_states on alternating automata

* tests/core/alternating.test: Run some of the test through
valgrind to exhibit the bug.
* spot/twa/twagraph.cc: Fix it.
parent 042c7a0f
// -*- coding: utf-8 -*-
// Copyright (C) 2014, 2015, 2016 Laboratoire de Recherche et Développement de
// l'Epita.
// Copyright (C) 2014, 2015, 2016, 2017 Laboratoire de Recherche et
// Développement de l'Epita.
//
// This file is part of Spot, a model checking library.
//
......@@ -300,7 +300,7 @@ namespace spot
todo.emplace_back(init_number_, 0U, begin, end);
}
do
for (;;)
{
unsigned& tid = std::get<1>(todo.back());
const unsigned*& begin = std::get<2>(todo.back());
......@@ -308,6 +308,8 @@ namespace spot
if (tid == 0U && begin == end)
{
todo.pop_back();
if (todo.empty())
break;
unsigned src = std::get<0>(todo.back());
if ((int)src >= 0)
order.emplace_back(src);
......@@ -334,7 +336,6 @@ namespace spot
todo.emplace_back(dst, succ, begin, end);
}
}
while (!todo.empty());
}
// Process states in topological order
......
#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2016 Laboratoire de Recherche et Développement de
# l'Epita (LRDE).
# Copyright (C) 2016, 2017 Laboratoire de Recherche et Développement
# de l'Epita (LRDE).
#
# This file is part of Spot, a model checking library.
#
......@@ -319,9 +319,9 @@ State: 3
--END--
EOF
autfilt --remove-unreachable-states ex4 > out4
run 0 autfilt --remove-unreachable-states ex4 > out4
diff expect4 out4
autfilt --remove-dead-states ex4 > out4
run 0 autfilt --remove-dead-states ex4 > out4
diff ex2 out4
......@@ -338,7 +338,7 @@ State: 1
--END--
EOF
autfilt --remove-dead-states ex5 > out5
run 0 autfilt --remove-dead-states ex5 > out5
cat >expect <<EOF
HOA: v1
States: 1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment