compiler not initializing a pointer correctly when use -s optimization
Bug #1270040 reported by
Stephen Wu
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Linaro Toolchain Binaries |
New
|
Undecided
|
Unassigned |
Bug Description
version: gcc-linaro-
Using other optimization options -0 -2 won't show this problem.
Code looks like this
#define SIGNATURE ('S' | ('I' << 8) | ('G' << 16) | ('N' << 24 ) )
typedef struct
{
uint32_t signature;
uint32_t revision;
} header_t;
typedef struct
{
header_t header;
void * ptr0;
void * ptr1;
.....
} struct_a;
struct_a A =
{
.header =
{
.signature = SIGNATURE,
.version = 0
},
ptr0 = ptra;
ptr1 = ptrb;
....
}
struct_a a_ptr = &A;
When the problem happen, the value of a_ptr becomes SIGNATURE, not the address of A.
To post a comment you must log in.
Thank you for the bug report. Can you provide a compilable testcase?