Skip to content
Snippets Groups Projects
Commit cb34c870 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Fix preprocessor crash when an pre-computed constant equals NaN or Inf

parent 906f5328
Branches
Tags
No related merge requests found
/* /*
* Copyright (C) 2003-2011 Dynare Team * Copyright (C) 2003-2012 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
...@@ -27,6 +27,7 @@ using namespace std; ...@@ -27,6 +27,7 @@ using namespace std;
#include <list> #include <list>
#include <sstream> #include <sstream>
#include <iomanip> #include <iomanip>
#include <cmath>
#include "SymbolTable.hh" #include "SymbolTable.hh"
#include "NumericalConstants.hh" #include "NumericalConstants.hh"
...@@ -261,6 +262,13 @@ public: ...@@ -261,6 +262,13 @@ public:
inline expr_t inline expr_t
DataTree::AddPossiblyNegativeConstant(double v) DataTree::AddPossiblyNegativeConstant(double v)
{ {
/* Treat NaN and Inf separately. In particular, under Windows, converting
them to a string does not work as expected */
if (isnan(v))
return NaN;
if (isinf(v))
return (v < 0 ? MinusInfinity : Infinity);
bool neg = false; bool neg = false;
if (v < 0) if (v < 0)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment