misc: fix some down_cast issues

We had new failure on MinGW with GCC believing that some pointer
returned by down_cast could be NULL; and the down_cast function was in
the global namespace.

* spot/misc/casts.hh: Rewrite.
* NEWS: Mention the small issues.
* tests/core/ikwiad.cc, tests/core/ngraph.cc: Adjust to use
spot::down_cast instead of down_cast.
This commit is contained in:
Alexandre Duret-Lutz 2018-01-10 17:30:25 +01:00
parent 91fdc5ecb2
commit 8a74ae6c9d
4 changed files with 30 additions and 102 deletions

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2007-2017 Laboratoire de Recherche et Développement
// Copyright (C) 2007-2018 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
// Copyright (C) 2003-2007 Laboratoire d'Informatique de Paris 6
// (LIP6), département Systèmes Répartis Coopératifs (SRC), Université
@ -1155,7 +1155,7 @@ checked_main(int argc, char** argv)
if (scc_filter && (reduction_dir_sim || reduction_rev_sim))
{
tm.start("SCC-filter post-sim");
auto aa = down_cast<spot::const_twa_graph_ptr>(a);
auto aa = spot::down_cast<spot::const_twa_graph_ptr>(a);
// Do not filter_all for SBA
a = spot::scc_filter(aa, assume_sba ?
false : scc_filter_all);

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2014-2017 Laboratoire de Recherche et Développement de
// Copyright (C) 2014-2018 Laboratoire de Recherche et Développement de
// l'Epita.
//
// This file is part of Spot, a model checking library.
@ -347,7 +347,7 @@ public:
int compare(const spot::state* other) const override
{
auto o = down_cast<const my_state*>(other);
auto o = spot::down_cast<const my_state*>(other);
// Do not simply return "other - this", it might not fit in an int.
if (o < this)