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

    <tr>
        <th>Summary</th>
        <td>
            [Clang] Non-fixed _BitInt typed enum constant not extended on overflow
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    https://c.godbolt.org/z/h7d5fKa4K
```C
#include <stdio.h>

int main() {
    enum {
    A = (_BitInt(33))0xFFFF'FFFF,
 B,
    X = _Generic(A, _BitInt(33): 1, default: 0),
    Y = _Generic(B, _BitInt(33): 1, default: 0)
    };

    printf("val A: %lld\n", (long long)A); // 4294967295
    printf("val B: %lld\n", (long long)B); // GCC: 4294967296, Clang: -4294967296
    printf("A is _BitInt(33): %d\n", (int)X); // 1
    printf("B is _BitInt(33): %d\n", (int)Y); // GCC: 0, Clang: 1
}
```

A has the `_BitInt(33)` type because the `0xFFFF'FFFF` value doesn't fit in `int` (for x86). 

B increments A to `0x1'0000'0000` which overflows `_BitInt(33)`, at this point Clang only issues a warning, while GCC extends to a larger type like non-_BitInt types would.

I think relevant text in standard is in 6.7.3.3-12 (N3220):
> (the type of enum constant shall be) ... 

> the type of the integer constant expression, if given explicitly with = and if the value of the
integer constant expression is not representable by int; or,

>  type of the value from the previous enumeration constant with one added to it. If such
an integer constant expression would overflow or wraparound the value of the previous
enumeration constant from the addition of one, the type takes on either:

> ... (suitably sized int type)
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVc2O2zoPfRplQ8SQ5fhvkYWTaYqiQNftqpAtOtY3ihRIcn769B9oJ7kz6fTiFhiMIpo8PIekJBmC3lvENcs3LH9ZyDEOzq_7cQjWLlqnrushxmNgWcPEjoldl-ydap2JifN7Jna_mNgNpcr7r3L1lfGGFXz-29JGZNp2Z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