Issue 147328
Summary Clang: compile implicitly an convertion from integral to enum class (error excepted)
Labels clang
Assignees
Reporter jonathanpoelen
    With this code:

```cpp
enum class E { a,b,c};

int main()
{  
  E e;    
  e = {1};
} 
```

Clang 18,19,20 and trunk compile without error.

Narrowing conversion gives a error, but the diagnostic is not appropriate:

```cpp
long long ll = 0;
e = {ll}; // non-constant-_expression_ cannot be narrowed from type
          // 'long long' to 'E' in initializer list [-Wc++11-narrowing]
```

Gcc:

```cpp
test.cpp: In function ‘int main()’:
test.cpp:6:9: error: cannot convert ‘<brace-enclosed initializer list>’ to ‘E’ in assignment
    6 |   e = {1};
      |         ^
```

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to