This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/37725] New: wrong struct initialization with non-constant expressions
- From: "disinbox at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Oct 2008 10:38:54 -0000
- Subject: [Bug c/37725] New: wrong struct initialization with non-constant expressions
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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