public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/48418] New: Bit shift operator >>=
@ 2011-04-02 20:30 lisp2d at lisp2d dot net
  2011-04-02 21:07 ` [Bug c/48418] " ebotcazou at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: lisp2d at lisp2d dot net @ 2011-04-02 20:30 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Bit shift operator >>=
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: lisp2d@lisp2d.net


int x=1000;
x>>=(sizeof(int)<<3);

x is still 1000

In some cases bit shift operator used with variable (not constant) and compiler
didnot show warning. My opinion is that result must be 0.

Remarked code in my program and code to see what's happened.

/*
ULong::ULong(ULInt    const&x):value2(){
    if(x.uli){
        if(sizeof(unsigned    int)==sizeof(unsigned    long    int)){
            value2.push_back(static_cast<unsigned    int>(x.uli));
            return;}
        UInt    const    ibs(sizeof(unsigned    int)<<3);
        ULInt    x2(x);
        do{
            value2.push_back(static_cast<unsigned    int>(x2.uli));
            (x2.uli)>>=(ibs.ui);
        }while(x2.uli);}}
*/
#include    <iostream>
typedef    struct{unsigned    int    i;}si;
int    main(void){
    unsigned    int    x=1000;
    si    w;
    w.i=sizeof(unsigned    int)<<3;
    std::cout<<"x="<<x<<std::endl;
    x>>=w.i;
    std::cout<<"x>>=w.i -> x="<<x<<std::endl;
    x>>=(sizeof(unsigned    int)<<3);
    std::cout<<"x>>=(sizeof(unsigned    int)<<3) -> x="<<x<<std::endl;
    x>>=32;
    std::cout<<"x>>=32 -> x="<<x<<std::endl;
}


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

end of thread, other threads:[~2013-02-01  9:11 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-02 20:30 [Bug c/48418] New: Bit shift operator >>= lisp2d at lisp2d dot net
2011-04-02 21:07 ` [Bug c/48418] " ebotcazou at gcc dot gnu.org
2011-04-02 21:43 ` d.g.gorbachev at gmail dot com
2011-04-03 11:09 ` [Bug c/48418] [4.5/4.6/4.7 Regression] " rguenth at gcc dot gnu.org
2011-04-03 11:21 ` joseph at codesourcery dot com
2011-04-10 10:47 ` rguenth at gcc dot gnu.org
2011-04-28 15:23 ` rguenth at gcc dot gnu.org
2011-08-24 20:52 ` pinskia at gcc dot gnu.org
2011-08-25  7:19 ` rguenth at gcc dot gnu.org
2012-07-02 11:25 ` [Bug c/48418] [4.5/4.6/4.7/4.8 " rguenth at gcc dot gnu.org
2013-01-08 14:45 ` [Bug c/48418] [4.6/4.7/4.8 " jakub at gcc dot gnu.org
2013-01-09 14:51 ` jakub at gcc dot gnu.org
2013-01-09 15:03 ` [Bug c/48418] [4.6/4.7 " jakub at gcc dot gnu.org
2013-02-01  9:11 ` jakub at gcc dot gnu.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).