This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug optimization/14299] New: Improperly derefences pointers with casting
- From: "dmeggy at techsol dot ca" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 25 Feb 2004 20:20:02 -0000
- Subject: [Bug optimization/14299] New: Improperly derefences pointers with casting
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Here is an example
<snip>
typedef struct
{
unsigned first : 6;
unsigned second : 1;
unsigned third : 1;
unsigned fourth : 1;
unsigned fifth : 1;
unsigned sixth : 1;
unsigned unused : 21;
} TestStruct;
int func() {
TestStruct a;
TestStruct *b;
a.first = 4;
b = (TestStruct *)(&a);
return b->first;
}
int func2() {
int a;
TestStruct *b;
a = 4;
b = (TestStruct *)(&a);
return b->first;
}
</snip>
func() will work, and func2() won't, called as "arm-linux-gcc test2.c -Os -g -c"
func2 will never set the value of a to 4
--
Summary: Improperly derefences pointers with casting
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dmeggy at techsol dot ca
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i386-linux
GCC host triplet: i386-linux
GCC target triplet: arm-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14299