<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/125180>125180</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Underlying type of unscoped and unfixed member enumerations of class templates
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          thebrandre
      </td>
    </tr>
</table>

<pre>
    If compatibility with MSVC is enabled, Clang correctly uses `int` as the underlying type of an unscoped enumeration even if the assigned integer causes an overflow - at least at namespace scope. This is correct in the sense of compatibility, which is officially documented by Microsoft [here](https://learn.microsoft.com/en-us/cpp/build/reference/zc-enumtypes?view=msvc-170).

However, if the same declaration appears inside a class template, `-fms-compatibility` is not honored. 

```cpp
template <typename T>
struct S {
    enum E { X, Y = 0xFFFFFFFF };
};

enum E { X, Y = 0xFFFFFFFF };

constexpr bool check(int) { return true; }
constexpr bool check(unsigned int) { return false; }

static_assert(check(E::X), ""); // succeeds
static_assert(check(S<char>::E::X), ""); // fails
```
See here on Compiler Explorer: https://godbolt.org/z/Ge8qehE5P

I am aware that there are a lot of open issues on the underlying type of enumerations when using `-fms-compatibility` (#120759 #122032 #1883 to name a few) but this one should be orthogonal.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVMFu4zYQ_ZrxZWCDJq1YPujg2FG7hwUKZFtsT8WIGllsKVIlKTvu1xdUnCbZIkXXEGDa4nucefP4KEZzcswVFPdQHBc0pd6HKvXcBHJt4EXj22v1qUPth5GSaYw16YoXk3r8_PjLAU1EdtRYbkEe8GDJnVD7EFgne8UpckS4E8YluBNIEVPPOLmWg70ad8J0HRl9h-RwclH7kVtkNw0cKBnvkM_s0HQz7FZsi8YlPnFATTM_OfRnDp31F1wiJbRMMeWFo4HjSJpxpl7hl97EXPKtQjRuZo7s4lzGuy5zQ5fe6D4jfNcZbcj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