public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/46517] New: Wrong result on left shift operator without optimization
@ 2010-11-17 9:37 lepinat at free dot fr
2010-11-17 10:01 ` [Bug c/46517] " schwab@linux-m68k.org
0 siblings, 1 reply; 2+ messages in thread
From: lepinat at free dot fr @ 2010-11-17 9:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46517
Summary: Wrong result on left shift operator without
optimization
Product: gcc
Version: 4.4.4
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: lepinat@free.fr
The next samples compiled without opimisation give not the same result
in both case if it's use has constante the result is good
(the test is on intel platfom)
#> gcc -o shift shift.c
result:
constant val=0
variable val=1
#> gcc -O2 -o shift shift.c
result:
constant val=0
variable val=0
On the first case is not a shift but it's rotate
you can verify by changing the constant:
example SHIFT = 34 the the result is
constant val=0
variable val=4
---->8---->8---->8---->8---->8
#include <stdio.h>
#define SHIFT (4*8)
int main(int argc, char* argv[])
{
int val = SHIFT;
printf("constant val=%x\n", (1<<SHIFT));
printf("variable val=%x\n", (1<<val));
return 0;
}
---->8---->8---->8---->8---->8
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c/46517] Wrong result on left shift operator without optimization
2010-11-17 9:37 [Bug c/46517] New: Wrong result on left shift operator without optimization lepinat at free dot fr
@ 2010-11-17 10:01 ` schwab@linux-m68k.org
0 siblings, 0 replies; 2+ messages in thread
From: schwab@linux-m68k.org @ 2010-11-17 10:01 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46517
Andreas Schwab <schwab@linux-m68k.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> 2010-11-17 09:45:15 UTC ---
.
*** This bug has been marked as a duplicate of bug 46460 ***
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-11-17 9:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-17 9:37 [Bug c/46517] New: Wrong result on left shift operator without optimization lepinat at free dot fr
2010-11-17 10:01 ` [Bug c/46517] " schwab@linux-m68k.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).