https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126287
Bug ID: 126287
Summary: ICE with counted_by and bitfields
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: sanitizer
Assignee: unassigned at gcc dot gnu.org
Reporter: uecker at gcc dot gnu.org
CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
jakub at gcc dot gnu.org, kcc at gcc dot gnu.org
Target Milestone: ---
The following code ICEs with -fsanitize=bounds.
struct foo {
#if 1
unsigned int FLOAT : 1;
unsigned int INT : 1;
#else
// this works
bool FLOAT;
bool INT;
#endif
union {
float a[] __attribute__((counted_by(FLOAT)));
int b[] __attribute__((counted_by(INT)));
};
};
int main()
{
struct foo x = { .FLOAT = 1 };
printf("%d\n", x.FLOAT);
x.a[0] = 1.;
printf("%d\n", x.INT);
x.b[0] = 1; // BOUNDS
}