llvm / llvm/llvm-project

[Clang] Clang-cl mode is bug-compatible with MSVC on completeness of enumeration types

Open
#169,472 3 comments 0 reactions 0 assignees View on GitHub
clang-cl clang:frontend
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

The following example should be rejected, because `E` is an enumeration type without fixed underlying type and thus incomplete within it's enumerator list. However, Clang currently accepts in Clang-cl mode ([demo](https://godbolt.org/z/8sr87nnj9)).

```C++
enum E {
n = sizeof(E),
};
```

[Another example](https://godbolt.org/z/rTsjf43s4) shows that the underlying type is assumed to be `int` here.

As MSVC is (incorrectly) doing the same, perhaps such behavior is kept for bug-compatibility. But given such "extension" can be undesired, because the underlying type can become another type when the enumeration becomes complete, perhaps we should consider turning it off by default, or even removing it one day.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.