[GiNaC-list] Potential issue in comparator in test_antipode
Yuri Gribov
tetra2005 at gmail.com
Sat Jun 4 09:22:35 CEST 2022
Hi,
The comparison in `node::operator<` in time_antipode.cpp seems to be
missing a dereference operation in return statement:
if (!(*vert==*n.vert))
return (vert<n.vert);
This causes the comparator to be non-transitive:
(gdb) p *keys[5] < *keys[4]
$5 = true
(gdb) p *keys[4] < *keys[8]
$6 = true
(gdb) p *keys[5] < *keys[8]
$7 = false
which violates the strict weak ordering requirements of std::map
(https://en.cppreference.com/w/cpp/named_req/Compare). Such violations
may in practice result in non-deterministic behavior or crashes.
The issue was found with [SortChecker++
tool](https://github.com/yugr/sortcheckxx).
Best regards,
Yuri Gribov
More information about the GiNaC-list
mailing list