[GiNaC-devel] remove_dirac_ONE() and documentation patches
Vladimir V. Kisil
kisilv at maths.leeds.ac.uk
Mon May 20 00:29:20 CEST 2019
Dear Alexey,
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.
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.
Best wishes,
Vladimir
--
Vladimir V. Kisil http://www.maths.leeds.ac.uk/~kisilv/
Book: Geometry of Mobius Transformations http://goo.gl/EaG2Vu
Software: Geometry of cycles http://moebinv.sourceforge.net/
>>>>> On Sun, 19 May 2019 19:31:06 +0400, Alexey Sheplyakov <asheplyakov at yandex.ru> said:
ASh> Hi,
>> Thus I re-write remove_dirac_ONE() without exceptions. The
>> signature of the method has to change, but a user may not
>> notice this in the first approximation.
ASh> There a few fatal differences (which are indeed not so easy to
ASh> spot):
ASh> - A user code might be relying on remove_dirac_ONE() to throw
ASh> an exception when something goes wrong. The patch breaks such
ASh> a code without a slightest warning from the compiler.
ASh> - Before the patch this:
ASh> remove_dirac_ONE(e, 0, 0);
ASh> used to compile and work just fine. With the patch it also
ASh> compiles (without a slightest warning), and segfaults at the
ASh> run time (for the last 0 is `bool *success` now).0
>> * @param e Expression to be processed - * @param rl Value of
>> representation label - * @param options Defines some internal use
>> */ -ex remove_dirac_ONE(const ex & e, unsigned char rl = 0,
>> unsigned options = 0); + * @param rl Value of representation
>> label, all dirac_ONE with this or greater value will be processed
>> + * @param success It is changed to false if there is at least
>> one clifford_unit() in the expression + * @param options Defines
>> some internal value for recursive calls, shall be ommited in user
>> code */ +ex remove_dirac_ONE(const ex & e, unsigned char rl = 0,
>> bool *success = new bool, unsigned options = 0);
ASh> Also there's a memory leak (since nobody is going to release
ASh> that `new bool`).
ASh> Therefore I think the patch is wrong and should not be applied.
ASh> Possible solutions:
ASh> 1)
ASh> a) Make a new (overload of) remove_dirac_ONE function:
ASh> ex remove_dirac_ONE(const ex& e, bool& success, unsigned
ASh> char rl = 0, unsigned options = 0);
ASh> which reports errors without exceptions
ASh> b) Don't change the behavior of the existing `ex
ASh> remove_dirac_ONE(const ex& e, unsigned char rl =0, unsigned
ASh> options = 0);
ASh> 2) Leave current `remove_dirac_ONE` as is. It's not broken,
ASh> there's nothing to fix.
>> The exceptions in remove_dirac_ONE() terminated a Qt Windows
>> application
ASh> And fix that application instead (perhaps I could help if the
ASh> sources and instructions how to reproduce the problem are
ASh> available)
ASh> Best regards, Alexey
ASh> _______________________________________________ GiNaC-devel
ASh> mailing list GiNaC-devel at ginac.de
ASh> https://www.cebix.net/mailman/listinfo/ginac-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Modify-remove_dirac_ONE-to-eliminate-exceptions.patch
Type: text/x-diff
Size: 11297 bytes
Desc: Revised patch
URL: <http://www.cebix.net/pipermail/ginac-devel/attachments/20190519/14d6bfa8/attachment.bin>
More information about the GiNaC-devel
mailing list