Make everything pass with optimizations turned on. This revealed two UB bugs:
best::vec<T> was manipulating size_ directly, even when this would violate strict aliasing. This caused some tests to fail because loading size_ would ignore stores made through data(), because &size_ and data() cannot alias because they have different types. size_ is now manipulated exclusively through memcpy().
A UAF in fnref_test.cc (but not best::fnref itself).
Since I was already touching best::fnref, I added a small optimization when constructing a best::fnref from a no-capture lambda.
Make everything pass with optimizations turned on. This revealed two UB bugs:
best::vec<T>
was manipulatingsize_
directly, even when this would violate strict aliasing. This caused some tests to fail because loadingsize_
would ignore stores made throughdata()
, because&size_
anddata()
cannot alias because they have different types.size_
is now manipulated exclusively throughmemcpy()
.A UAF in
fnref_test.cc
(but notbest::fnref
itself).Since I was already touching
best::fnref
, I added a small optimization when constructing abest::fnref
from a no-capture lambda.