This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/33887] [4.1/4.2/4.3 Regression] Reference to bitfield gets wrong value when optimizing
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Jan 2008 15:45:41 -0000
- Subject: [Bug c++/33887] [4.1/4.2/4.3 Regression] Reference to bitfield gets wrong value when optimizing
- References: <bug-33887-1313@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #19 from rguenth at gcc dot gnu dot org 2008-01-14 15:45 -------
The bug here is that the FE does not perform integer promotion for ++sv.f2,
but emits
<<cleanup_point <<< Unknown tree: expr_stmt
(void) ++sv.f2 >>>
>>;
which is gimplified to operations on a bitfield type:
<unnamed-unsigned:24> D.2043;
<unnamed-unsigned:24> D.2044;
D.2043 = sv.f2;
D.2044 = D.2043 + 1;
sv.f2 = D.2044;
Once the optimizer realizes it doesn't need to go through memory for sv.f2,
things go downhill, as expand now reaches D.2043 + 1 without the implicit
truncation done at the store to memory.
See my bitfield rant on gcc@ - it's all broke.
The proper C++ FE fix is to perform arithmetic in a promoted type here.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |rguenth at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Last reconfirmed|2007-12-08 20:07:32 |2008-01-14 15:45:40
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33887