public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug regression/32687] New: Invalid code generation for reading signed negative bitfield value (g++ optimization)
@ 2007-07-09 6:18 siarhei dot siamashka at gmail dot com
2007-07-09 7:18 ` [Bug c++/32687] " pinskia at gcc dot gnu dot org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: siarhei dot siamashka at gmail dot com @ 2007-07-09 6:18 UTC (permalink / raw)
To: gcc-bugs
Reading signed bitfield value when it needs to be extended to larger type (for
example assigning 24-bit value to int) results in zero extending instead of
sign extending when compiled with g++ using optimizations (-O1 or higher).
Compiling the same code with gcc or disabling optimizations makes the problem
disappear.
The following code reproduces the problem:
#include <stdio.h>
struct TEST_STRUCT
{
int f_8 : 8;
int f_24 : 24;
};
int main ()
{
struct TEST_STRUCT x;
int a = -123;
x.f_24 = a;
printf("a=%d (%08X)\n", (int)a, (int)a);
printf("x.f_24=%d (%08X)\n", (int)x.f_24, (int)x.f_24);
if ((int)x.f_24 != (int)a)
printf("test failed\n");
else
printf("test ok\n");
return 0;
}
////////////////////////////////
Expected correct result:
a=-123 (FFFFFF85)
x.f_24=-123 (FFFFFF85)
test ok
Faulty result:
a=-123 (FFFFFF85)
x.f_24=16777093 (00FFFF85)
test failed
It is a regression as gcc 3.4.6 did not have this bug. Also this problem may be
related to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32346 and
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30332
--
Summary: Invalid code generation for reading signed negative
bitfield value (g++ optimization)
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: regression
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: siarhei dot siamashka at gmail dot com
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32687
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/32687] Invalid code generation for reading signed negative bitfield value (g++ optimization)
2007-07-09 6:18 [Bug regression/32687] New: Invalid code generation for reading signed negative bitfield value (g++ optimization) siarhei dot siamashka at gmail dot com
@ 2007-07-09 7:18 ` pinskia at gcc dot gnu dot org
2007-07-11 7:06 ` siarhei dot siamashka at gmail dot com
2008-11-14 0:22 ` jason at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-07-09 7:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2007-07-09 07:17 -------
Works on the trunk correctly.
Related to PR 31136.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
BugsThisDependsOn| |31136
Keywords| |wrong-code
Known to work|3.4.6 |3.4.6 4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32687
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/32687] Invalid code generation for reading signed negative bitfield value (g++ optimization)
2007-07-09 6:18 [Bug regression/32687] New: Invalid code generation for reading signed negative bitfield value (g++ optimization) siarhei dot siamashka at gmail dot com
2007-07-09 7:18 ` [Bug c++/32687] " pinskia at gcc dot gnu dot org
@ 2007-07-11 7:06 ` siarhei dot siamashka at gmail dot com
2008-11-14 0:22 ` jason at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: siarhei dot siamashka at gmail dot com @ 2007-07-11 7:06 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from siarhei dot siamashka at gmail dot com 2007-07-11 07:06 -------
Tried this test with gcc 4.2.0, it also works correctly. So looks like the
problem only shows up in gcc 4.1.x
--
siarhei dot siamashka at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work|3.4.6 4.3.0 |3.4.6 4.2.0 4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32687
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/32687] Invalid code generation for reading signed negative bitfield value (g++ optimization)
2007-07-09 6:18 [Bug regression/32687] New: Invalid code generation for reading signed negative bitfield value (g++ optimization) siarhei dot siamashka at gmail dot com
2007-07-09 7:18 ` [Bug c++/32687] " pinskia at gcc dot gnu dot org
2007-07-11 7:06 ` siarhei dot siamashka at gmail dot com
@ 2008-11-14 0:22 ` jason at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu dot org @ 2008-11-14 0:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from jason at gcc dot gnu dot org 2008-11-14 00:21 -------
The 4.1 series is closed, so this is now fixed in all current release series.
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32687
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-11-14 0:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-09 6:18 [Bug regression/32687] New: Invalid code generation for reading signed negative bitfield value (g++ optimization) siarhei dot siamashka at gmail dot com
2007-07-09 7:18 ` [Bug c++/32687] " pinskia at gcc dot gnu dot org
2007-07-11 7:06 ` siarhei dot siamashka at gmail dot com
2008-11-14 0:22 ` jason at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).