According to the C++ standard, the stored pointer and the stored deleter
should be value-initialized.
Details
- Reviewers
ldionne - Group Reviewers
Restricted Project - Commits
- rG68e2231f8724: [libc++] Value-initialize unique_ptr's deleter_type
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
Thanks for the review! I just noticed the diff from the spec.
I can't believe I missed those two cases. I made the changes and added another test case.
I also noticed there's a missing value initialization in the constructor taking an auto_ptr. But I was not able to run the auto_pointer.pass.cpp test because it was marked as unsupported.
Should we update that constructor as well, and if so, how do I run the test?
Wait, scratch that, the auto_ptr constructor should be disable with a non-default deleter, so I guess it doesn't really make any difference.
It looks like the auto_ptr test requires C++11 or C++14. You can see how to run the test suite with different parameters here: https://libcxx.llvm.org/TestingLibcxx.html#usage
Long story short, you can do:
<build-dir>/bin/llvm-lit -sv libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/auto_pointer.pass.cpp --param std=c++14
Thanks, that did the trick!
I've added value-initialization to the auto_ptr constructor to match the spec, however, I'm not able to add a test for this specific case since this constructor is disabled for non-default deleters. The current tests for the auto_ptr constructor are still passing after the change.
Can you please rebase onto main? That will re-trigger CI and it should pass.
Also, if you want me to commit this for you, please provide Author Name <email@domain>. Thanks!
We have the same problem here AFAICT.