https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102538
Bug ID: 102538
Summary: Wrong narrowing conversion checking for initializer
with union
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: kito at gcc dot gnu.org
Target Milestone: ---
How to reproduce:
g++ x.cpp
Testcase:
```
#include <stdint.h>
struct X {
union {
uint8_t r8[8];
uint32_t r32[2];
};
};
struct ctx {
X v[1];
};
ctx x = {
{
{.r32 = {5,0x33333}},
}
};
```
Message:
x.cpp:19:1: error: narrowing conversion of '209715' from 'int' to 'uint8_t'
{aka 'unsigned char'} [-Wnarrowing]
19 | };
| ^
Work with GCC 11.1 but not work with GCC 11.2 and trunk