Issue 173711
Summary [libc++] `__bit_reference::operator&` doesn't seem conforming
Labels libc++
Assignees
Reporter frederick-vs-ja
    libc++ has been providing `operator&` for `__bit_reference` since the initial commit.

https://github.com/llvm/llvm-project/blob/b9ada74a667c07456ea51e5a2d75788a421c5950/libcxx/include/__bit_reference#L169-L171

However, the C++ standard doesn't specify unary `operator&` for any standard library type other than `constant_wrapper` (see [[const.wrap.class]](https://eel.is/c++draft/const.wrap.class)). Moreover, operations for `bitset<N>::reference` and `vector<bool, A>::reference` seem to be fully specified, so `&` on them probably need to have built-in semantics.

As a result, the `operator&` doesn't seem conforming. The behavioral difference is very observable. ([Godbolt link](https://godbolt.org/z/46EdPMY94))
```C++
#include <bitset>

static_assert([]{
  std::bitset<1> s;
  auto r1 = s[0];
  auto r2 = s[0];

  return &r1 != &r2;
}());
```

(`__bit_const_reference` also has `operator&`. But given `__bit_const_reference` is never a standard-specified type, the `operator&` seems to be fine.)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to