Dear All, 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. 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. 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/ Jupyter (Colab): https://github.com/vvkisil/MoebInv-notebooks Jupyter (CodeOcean): http://doi.org/10.24433/CO.9934595.v2 ====================================== #include <iostream> #include <fstream> #include <stdexcept> #include <ginac/ginac.h> using namespace std; using namespace GiNaC; int main(int argc, char** argv) { ex x = lst{1,2}, y = lst{3}, z = lst{}; GiNaC::archive A; A.archive_ex(x, "2elem"); A.archive_ex(y, "1elem"); A.archive_ex(z, "empty"); ofstream out("/tmp/test.gar", ios::binary); out << A; out.flush(); out.close(); GiNaC::archive A1; std::ifstream ifs("/tmp/test.gar", std::ifstream::in | ios::binary); ifs >> A1; ex x1 = A1.unarchive_ex(lst{}, "2elem") ; ex y1 = A1.unarchive_ex(lst{}, "1elem") ; ex z1 = A1.unarchive_ex(lst{}, "empty") ; x1.dbgprint(); // -> {1,2} y1.dbgprint(); // -> {3} z1.dbgprint(); // -> {1} return 0; }