This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Avoid spurious construction of valarray elements
ClosedPublic

Authored by miyuki on Jan 12 2018, 6:33 AM.

Details

Summary

Currently libc++ implements some operations on valarray by using the
resize method. This method has a parameter with a default value.
Because of this, valarray may spuriously construct and destruct
objects of valarray's element type.

This patch fixes this issue and adds corresponding test cases.

Diff Detail

Repository
rCXX libc++

Event Timeline

miyuki created this revision.Jan 12 2018, 6:33 AM
mclow.lists accepted this revision.Feb 7 2018, 10:06 AM

This LGTM.

include/valarray
3728

I thought that you had lost an exception guarantee here, but it turns out that there wasn't one before. If the allocation fails, you are left with an empty array instead of the old contents.

This revision is now accepted and ready to land.Feb 7 2018, 10:06 AM
This revision was automatically updated to reflect the committed changes.