Issue 75924
Summary missing branch coverage in defaulted operator<=>
Labels new issue
Assignees
Reporter hanickadot
    For code:

```c++
#include <compare>

struct foo {
  char value;
  friend auto operator<=>(foo, foo) = default;
};

int main() {
  auto a1 = foo{0} <=> foo{1};
  auto a2 = foo{1} <=> foo{0};
  auto a3 = foo{0} <=> foo{0};
}
```

There shouldn't be any missing branch. But some `false` path is never taken. This makes 100% test-coverage impossible.

```
    1|       |#include <compare>
    2| |
    3|       |struct foo {
    4|       |  char value;
    5| 15|  friend auto operator<=>(foo, foo) = default;
  ------------------
 |  Branch (5:45): [True: 100.00%, False: 0.00%]
  ------------------
 6|       |};
    7|       |
    8|      1|int main() {
    9| 1|  auto a1 = foo{0} <=> foo{1};
   10|      1|  auto a2 = foo{1} <=> foo{0};
   11|      1|  auto a3 = foo{0} <=> foo{0};
   12| 1|}
   ```
   
This happens to other types I tried even `std::string`
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to