Problem report

Christian Bauer Christian.Bauer at Uni-Mainz.DE
Sun Oct 26 17:58:32 CET 2003


Hi!

On Fri, Oct 24, 2003 at 11:01:15AM +0100, John Fletcher wrote:
>  symbol x("x");
>  ex example("x+1",lst(x));
>
>  // This produces a compile time message
>  // Internal error: statement in file real/conv/cl_R_to_double.cc, 
>  // line 55 has been reached!!
>  // Please send the authors of the program a description 
>  // how you produced this error!
>
>  double val = ( ex_to<numeric>( example ) ).to_double();

You call ex_to<numeric>(example), but 'example' is a sum, not a numeric.
When you call ex_to<T> on an expression that isn't a T, you're in deep
doodoo. You should check the type of the expression first, like this:

  double val;
  if (is_a<numeric>(example))
    val = ex_to<numeric>(example).to_double();
  else
    // report error, load 'val' with default value, or something else

Bye,
Christian

-- 
  / Physics is an algorithm
\/ http://www.uni-mainz.de/~bauec002/



More information about the GiNaC-devel mailing list