The default ones may do the wrong thing, for example perform a shallow copy instead of a deep copy. Disable them so they don't get accidentally used.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Sounds good - maybe add some static_asserts in the unit test to validate that these operations are appropriately deleted? & could you make the comment more definitive - "Delete these operations as the defaults would be shallow/cause incorrect shared state. Implement these if/when needed/worthwhile to do so." or something like that.
llvm/include/llvm/ADT/IntervalMap.h | ||
---|---|---|
1052 | This isn't quite accurate - the "std::pair" situation came up only on FreeBSD when std::pair of trivially copyable types wasn't itself trivially copyable. The general statement is true for any case where the value type is not trivially copyable, but maybe that's not worth mentioning in a comment here? Enough to say that these operations wouldn't be correct (regardless of whether the incorrectness/failure is a compile time or runtime issue?) So I'd probably just remove this two line comment, keep the one above. |
llvm/include/llvm/ADT/IntervalMap.h | ||
---|---|---|
1052 | I mentioned it because the deletions of operator= here don't actually do anything, and the static asserts in the test will succeed regardless of whether they are present or not. |
llvm/include/llvm/ADT/IntervalMap.h | ||
---|---|---|
1052 | Fair enough - thanks for the context |
This isn't quite accurate - the "std::pair" situation came up only on FreeBSD when std::pair of trivially copyable types wasn't itself trivially copyable. The general statement is true for any case where the value type is not trivially copyable, but maybe that's not worth mentioning in a comment here? Enough to say that these operations wouldn't be correct (regardless of whether the incorrectness/failure is a compile time or runtime issue?)
So I'd probably just remove this two line comment, keep the one above.