| Issue |
52902
|
| Summary |
[libc++] constexpr copy assignment of vector::iterator assigns nothing under _LIBCPP_DEBUG_LEVEL == 2
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
cneumann
|
This seems to be introduced by 6146e4cf89dbd5d9627c4694e0bea9d4c0fc6e0b.
Looking at the definition in [_wrap_iter.h](https://github.com/llvm/llvm-project/blob/0edf99950e6234159c99710838f21d3629d756af/libcxx/include/__iterator/wrap_iter.h#L75) the actual assignment step is guarded against self assignment AND being executed under `__libcpp_is_constant_evaluated` - I think the latter should only guard the debug tracking like in other member functions.
A fixed version could look like:
```c++
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
__wrap_iter& operator=(const __wrap_iter& __x)
{
if (this != _VSTD::addressof(__x))
{
if (!__libcpp_is_constant_evaluated())
__get_db()->__iterator_copy(this, _VSTD::addressof(__x));
__i = __x.__i;
}
return *this;
}
```
Or alternatively (since self assignment seems harmless in this case):
```c++
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
__wrap_iter& operator=(const __wrap_iter& __x)
{
if (this != _VSTD::addressof(__x) && !__libcpp_is_constant_evaluated())
__get_db()->__iterator_copy(this, _VSTD::addressof(__x));
__i = __x.__i;
return *this;
}
```
Without `_LIBCPP_DEBUG_LEVEL == 2` the copy assignment operator is (implicitly) defaulted, so the problem does not happen there.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs