BigUglySpider / EmuLibs

Selection of libraries designed to be used with Emu projects. This was originally a Math library only, but has since been changed to hold all Emu libraries to enable consistency in changes to dependencies (such as EmuCore modifications).
https://biguglyspider.github.io/math
0 stars 0 forks source link

[EmuMath] (Minor) Potential reuse of moved-from elements when constructing/copying from rvalue Vectors/Matrices of references #45

Closed BigUglySpider closed 1 year ago

BigUglySpider commented 2 years ago

Taken verbatim from commit f75fc15612706422361b6d37db41b9155edde331:

A minor, but not especially safe, issue has become clear with areas where visual studio's false-positive warnings are silenced. Although we never access the same index twice when allowing moves, we could potentially be moving from a reference Vector/Matrix which, although unlikely, could contain multiple references to the same object, which results in actually repeated-using a moved-from object.


This is, as said in the quote, low-priority due to the highly niche scenario that it would pose a problem. This issue is being made so that the problem is known, and something can be done regarding it.

This scenario would be fine were it not for visual studio's false-positive warnings, but as we are silencing a potential legitimate case something should be done to accommodate for this.

Removing the warning silencing is not an option until false-positives are corrected, as warnings about reusing moved-from items (which have actually not been moved) pollute program output information in many legitimate, safe cases.

One proposal may be to prevent reference-containing Vectors/Matrices from being moved from, but this eliminates the ability to select a series of items not stored together to be moved into a single contiguous location.

BigUglySpider commented 1 year ago

Under the current implementation (unless defective), this is not an issue; the EmuMath standard does not permit automated moving when containing references instead of values.

This may still be an issue in a defective implementation somewhere, but this is no longer a direct issue with the EmuMath definition of what these types should do.