[GiNaC-list] Bug with evalm()?

Martin Sandve Alnæs martinal at simula.no
Fri Feb 9 17:39:50 CET 2007


I use ginac 1.3.4.

I believe there is a bug in the implementation of evalm().
Its behaviour should be to do nothing if it is not applicable to
the ex it is called on, right? The minimal example below throws an exception:


#include <ginac/ginac.h>

using namespace std;
using namespace GiNaC;

int main(int argc, char **argv)
{
  ex x = symbol("x");
  ex e = sin(x);
  ex s = e.series(x == 0, 3);
  cout << "This will crash:" << endl;
  ex m = s.evalm();
  return 0;
}


The error is:

terminate called after throwing an instance of 'std::range_error'
  what():  basic::let_op(): pseries has no operands
Aborted (core dumped)


The call stack from gdb is:

(gdb) where
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb7b12770 in raise () from /lib/tls/i686/cmov/libc.so.6
#2  0xb7b13ef3 in abort () from /lib/tls/i686/cmov/libc.so.6
#3  0xb7d02520 in __gnu_cxx::__verbose_terminate_handler () from
/usr/lib/libstdc++.so.6
#4  0xb7cfff55 in std::set_unexpected () from /usr/lib/libstdc++.so.6
#5  0xb7cfff92 in std::terminate () from /usr/lib/libstdc++.so.6
#6  0xb7d000ca in __cxa_throw () from /usr/lib/libstdc++.so.6
#7  0xb7d9a4a6 in GiNaC::basic::let_op (this=0x80597d8, i=1) at basic.cpp:256
#8  0xb7d96dfd in GiNaC::basic::map (this=0x80595e0, f=@0xb7f8e824) at
basic.cpp:316
#9  0xb7d962a9 in GiNaC::basic::evalm (this=0x80595e0) at basic.cpp:482
#10 0x0804b47a in GiNaC::ex::evalm (this=0xbfd820d4) at
/usr/include/ginac/ex.h:118
#11 0x0804b214 in main () at test.cpp:12


Of course, it doesn't make much sense to call evalm() on this
expression, but it is a problem in an application where we want to
call evalm() "just in case" on all ex objects that pass a certain
point in the application. Thus a "do nothing" behaviour for evalm() is
of great importance.

martin


More information about the GiNaC-list mailing list