public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/28195]  New: << (shift operator) does rotate operation
@ 2006-06-28 17:57 tetsuji dot rai at gmail dot com
  2006-06-28 18:02 ` [Bug c/28195] " falk at debian dot org
  2006-06-29  9:02 ` tetsuji dot rai at gmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: tetsuji dot rai at gmail dot com @ 2006-06-28 17:57 UTC (permalink / raw)
  To: gcc-bugs

When shift count is the same as the length of a variable (eg, l << 32 where
long int l;), this doesn't return 0, instead it returns a rotated value.

Below is assumed to return 0, but actually returns 2468.

---t2.c---(test case)
#include <stdio.h>

long long ll;
long l;

int
main(){
  l = 1234;
  ll = l << 33;
  printf("%lld\n", ll);

  return 0;
}
--------------------


-- 
           Summary: << (shift operator) does rotate operation
           Product: gcc
           Version: 3.4.6
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tetsuji dot rai at gmail dot com
 GCC build triplet: ia32 Gentoo Linux
  GCC host triplet: ia32 Gentoo Linux
GCC target triplet: ia32 Gentoo Linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28195


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/28195] << (shift operator) does rotate operation
  2006-06-28 17:57 [Bug c/28195] New: << (shift operator) does rotate operation tetsuji dot rai at gmail dot com
@ 2006-06-28 18:02 ` falk at debian dot org
  2006-06-29  9:02 ` tetsuji dot rai at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: falk at debian dot org @ 2006-06-28 18:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from falk at debian dot org  2006-06-28 17:57 -------
Shifting by an amount larger than the size of a type is undefined behavior,
so anything might happen. Gcc even warns about this.


-- 

falk at debian dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28195


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/28195] << (shift operator) does rotate operation
  2006-06-28 17:57 [Bug c/28195] New: << (shift operator) does rotate operation tetsuji dot rai at gmail dot com
  2006-06-28 18:02 ` [Bug c/28195] " falk at debian dot org
@ 2006-06-29  9:02 ` tetsuji dot rai at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: tetsuji dot rai at gmail dot com @ 2006-06-29  9:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from tetsuji dot rai at gmail dot com  2006-06-29 07:30 -------
sorry and thanks.  my mistake.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28195


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-06-29  7:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-28 17:57 [Bug c/28195] New: << (shift operator) does rotate operation tetsuji dot rai at gmail dot com
2006-06-28 18:02 ` [Bug c/28195] " falk at debian dot org
2006-06-29  9:02 ` tetsuji dot rai at gmail dot com

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).