[Bug c/37725] New: wrong struct initialization with non-constant expressions
disinbox at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Oct 3 10:40:00 GMT 2008
test case:
#include <stdio.h>
typedef struct {
unsigned int a;
unsigned int b;
unsigned int c;
unsigned int d;
} Head;
void f()
{
unsigned int offsetVar=sizeof(Head);
Head h={
1,
2,
offsetVar,
offsetVar+=sizeof(unsigned int)
};
printf("%d\t%d\t%d\t%d\n", h.a, h.b, h.c, h.d);
}
int main()
{
f();
return 0;
}
expected results:
1 2 16 20
actual results:
1 2 20 20
declaring offsetVar as volatile hides the problem
--
Summary: wrong struct initialization with non-constant
expressions
Product: gcc
Version: 4.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: disinbox at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37725
More information about the Gcc-bugs
mailing list