This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/51759] [4.5 Regression] miscompile writes past end of bitfield
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 05 Jan 2012 10:00:37 +0000
- Subject: [Bug tree-optimization/51759] [4.5 Regression] miscompile writes past end of bitfield
- Auto-submitted: auto-generated
- References: <bug-51759-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51759
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Known to work| |4.4.6, 4.6.0
Keywords| |wrong-code
Last reconfirmed| |2012-01-05
Component|c++ |tree-optimization
CC| |jamborm at gcc dot gnu.org
Ever Confirmed|0 |1
Summary|miscompile writes past end |[4.5 Regression] miscompile
|of bitfield |writes past end of bitfield
Target Milestone|--- |4.5.4
--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-01-05 10:00:37 UTC ---
It's a bug in IPA-SRA that creates non-mode-size stores:
void llvm::Type::_ZN4llvm4Type15setSubclassDataEj.clone.1(unsigned int:24*,
unsigned int) (<unnamed-unsigned:24> * ISRA.6, unsigned int val)
{
...
<bb 2>:
D.87358_2 = (<unnamed-unsigned:24>) val_1(D);
*ISRA.6_8(D) = D.87358_2;
I think this has been fixed in 4.6 (not on the 4.5 branch though) which
no longer performs this substitution. You can work around this using
-fno-ipa-sra.
The following is a simplified testcase:
extern "C" void abort (void);
struct S
{
void __attribute__((noinline)) set(unsigned val)
{
data = val;
if (data != val)
abort ();
}
int pad0;
unsigned pad1 : 8;
unsigned data : 24;
int pad2;
};
int main()
{
S s;
s.pad2 = -1;
s.set(0);
if (s.pad2 != -1)
abort ();
}
Where 4.6 says:
Candidate (2069): this
! Disqualifying this - Encountered a bit-field access.
which hints at what needs backporting.
Martin?