[GiNaC-devel] remove_dirac_ONE() and documentation patches

Alexey Sheplyakov asheplyakov at yandex.ru
Mon May 20 16:06:38 CEST 2019


Hello,

20.05.2019, 02:29, "Vladimir V. Kisil" <kisilv at maths.leeds.ac.uk>:

>         Many thanks for the useful suggestions. I have revised my patch
>   in accordance with your first suggestion: both the old and the new
>   version are present. This patch is attached below.

This version  looks better, but 

> +ex remove_dirac_ONE(const ex & e, bool *success, unsigned char rl = 0, unsigned options = 0);
> +

it still subtly changes the meaning of

remove_dirac_ONE(e, 0, 0);

Before the patch it was remove_dirac_ONE(e, /* rl = */ 0, /* options = */ 0), and with patch it's
remove_dirac_ONE(e, /* success = */ 0, /* rl = */ 0) which  

1) does not throw an exception on error
2) segfaults

Please change the prototype (of the non-throwing function) to

ex remove_dirac_ONE(const ex& e, bool& success, unsigned char rl = 0, unsigned options = 0);

This way the compiler can pick the correct overload

e = remove_dirac_ONE(e, 0, 0); // OK: remove_dirac_ONE(const ex&, unsigned char, unsigned)
bool ok = false;
e = remove_dirac_ONE(e, ok, 0, 0);


>   Regarding crashes of my application the situation was solved by
>   partial substitution: I was able to avoid crashes keeping the original
>   version of GiNaC. It was enough to replace calls to exception-free
>   version of remove_dirac_ONE to in my library only. Probably exceptions
>   work fine within one library but create crashes if passed between
>   different libraries.

I don't quite understand how patching *just* remove_dirac_ONE could possibly
avoid the cross-DLL exceptions problem. See, many (most?) GiNaC methods and
functions use exceptions to report an error. For instance, pseries::power_const
throws pole_error. Why this one is not a problem? What's special about remove_dirac_ONE?


Best regards,
     Alexey


More information about the GiNaC-devel mailing list