[GiNaC-devel] Archiving an empty container

Richard B. Kreckel kreckel at in.terlu.de
Tue Sep 10 10:27:16 CEST 2019


Hi Vladimir,

On 09.09.19 16:07, Vladimir V. Kisil wrote:
> 	There is an issue with GiNaC archiving an empty container. This
>   is illustrated by the code included below. The archived empty list z
>   is read in the expression z1 as a list with one element. Also such
>   code can crashes id an empty container is archived first.
> 
>   The reason is in lines 215-216 of container.h: here GiNaC got
>   first=last for both: empty containers and containers with one element.

Thanks a lot for researching and reporting this!

>   I propose the attached patch, which modifies the return value of
>   archive_node::find_last() (called at line 216 of container.h) by 1.
>   All other calls of archive_node::find_last() are revised to agree with
>   the change.

I'm not convinced that changing archive_node::find_last(name) to return
an iterator to a property beyond the one searched for is the right fix.

It might break existing code. Also, it's not intuitive in the presence
of archive_node::find_first(name). This is not like T::begin() and
T::end() - notice the different naming!

Would it not be better to add something to the interface of class
archive_node, like an empty() function or so?

All my best,
   -richy.
-- 
Richard B. Kreckel
<https://in.terlu.de/~kreckel/>


More information about the GiNaC-devel mailing list