[v3] libstdc++/33489

Johannes Singler singler@ira.uka.de
Mon Oct 8 15:05:00 GMT 2007


Benjamin Kosnik wrote:
> Here are the low-hanging fixes for this issue. Fixed are nth_element,
> set_difference, set_intersection, set_symmetric_difference, set_union.

This fix will not work in all cases.
That's the major change for multiseq_selection.h:

    bool maxleftset = false, minrightset = false;
-    T maxleft, minright;	// Impossible to avoid the warning?
+    value_type maxleft(S(0)[a[0] - 1]);
+    value_type minright(S(0)[b[0]]);

However, the referenced elements might not exist (a[0] == 0 or b[0] too
large) in corner cases, even if all the sequences are non-empty. That's
also the reason why the *set flags exist. We should use pointers
instead. They could replace the *set flags as well (e. g. maxleft ==
NULL corresponds to maxleftset == false).

The other changes are minor and look OK.

> Seems like maybe std::vector could be used here...

Since we only refer to existing elements, we should be able to use
pointers and/or references in all erroneous cases, in principle.

Johannes



More information about the Libstdc++ mailing list