| Issue |
124260
|
| Summary |
Clang Accepts Ambiguous Conditional Expressions Involving Deleted Functions
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
ckwastra
|
Clang accepts the following code ([Godbolt](https://godbolt.org/z/ejs7GK9Kb)):
```cpp
#include <type_traits>
#include <utility>
using namespace std;
struct S {
S(int) = delete;
operator int();
};
// Clang: T = int, GCC/MSVC: <Ambiguous>
using T = decltype(true ? declval<S>() : declval<int>());
static_assert(is_same_v<T, int>);
```
The conditional _expression_ in this code is ambiguous because there exists an implicit conversion sequence (ICS) from `S` to `int` and another one in the opposite direction, resulting in an ill-formed program according to [[expr.cond]/4](https://timsong-cpp.github.io/cppwp/n4950/expr.cond#4):
> [...] If both sequences can be formed, or one can be formed but it is the ambiguous conversion sequence, the program is ill-formed. [...]
Clang appears to take `delete` into account when forming ICSs, which contradicts the guidance in [Note 2](https://timsong-cpp.github.io/cppwp/n4950/expr.cond#note-2) of the standard:
> Properties such as access, whether an operand is a bit-field, or whether a conversion function is deleted are ignored for that determination.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs