[Bug tree-optimization/30913] New: SRA bugs with anon bitfields
jakub at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Wed Feb 21 14:28:00 GMT 2007
// gcc -O2 -Wall -S uninit-anon-bitfield.c
struct foo {
unsigned int a:16;
unsigned int b:11;
unsigned int :5;
};
extern struct foo bar;
void foo(int a, int b)
{
struct foo tmp;
tmp.a = a;
tmp.b = b;
bar = tmp;
}
warns while it should not, the anon bitfield is just a padding, can't be
assigned to. There is no warning with -fno-tree-sra.
The bug is in SRA IMHO, when scalarizing a struct assignment, it should
certainly
ignore the anon bitfields (TREE_CODE (x->element) == FIELD_DECL && DECL_NAME
(x->element) == NULL && TREE_CODE (TREE_TYPE (x->element)) == BIT_FIELD_TYPE
?).
Both in generate_element_copy, generate_copy_inout and perhaps in other places
as well. Or not instantiate the anon bitfields at all.
There is another bug, e.g. for
struct foo {
unsigned int a:16;
unsigned int b:11;
unsigned int :5;
};
extern struct foo bar;
void foo(struct foo a)
{
struct foo tmp;
tmp = a;
bar = tmp;
}
SRA certainly should not have decided to use element copies at all, that makes
many times worse code.
--
Summary: SRA bugs with anon bitfields
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jakub at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30913
More information about the Gcc-bugs
mailing list