[PTLsim-devel] Bug in Bitvec

abhishek
Wed Oct 10 21:55:55 EDT 2007


OOps !! 

I got confused by the way bitvec data was printed. So, I mistook lsb for
msb and so on.

Sorry for the spam.

abhishek

On Wed, 2007-10-10 at 20:49 -0400, Matt T. Yourst wrote:
> On Wednesday 10 October 2007 19:09, abhishek wrote:
> > Hey Matt,
> >
> > It appears that the rightshift and leftshift implementations of bitvec
> > class are swapped. I've fixed superstl.h and is attached along  with the
> > mail. You might wanna review it and check-in. The changes have been made
> > over rvn-225.
> >
> 
> I looked at your changes and they don't make sense. Are you sure you sent me 
> the correct file?
> 
> Without your patch, the existing rev 225 version of superstl.h seems correct.
> 
> This simple program works correctly:
> 
>     bitvec<256> v = 0x12345678;
>     cout << hexstring(v.integer(), 64), endl;
>     v >>= 8;
>     cout << hexstring(v.integer(), 64), endl;
> 
> The printed output is 0x12345678, 0x123456, which is correct.
> 
> Also, this part of your patch is just plain wrong;
> 
> Old version:
>     void shiftleftop(size_t __shift) { w <<= __shift; }
>     void shiftrightop(size_t __shift) { w >>= __shift; }
> 
> New version (switched the shift direction);
>     void shiftrightop(size_t __shift) { w <<= __shift; }
>     void shiftleftop(size_t __shift) { w >>= __shift; }
> 
> With your changes, the normal non-overloaded left shift ("<<") C++ operator is 
> used with shiftrightop (i.e. called for right shifts), which is obviously not 
> correct nor consistent with the meaning of the ">>" and "<<" operators.
> 
> Am I missing something here? Did you try running test programs with your 
> changes? I think it will very quickly break.
> 
> - Matt
> 
> -------------------------------------------------------
>  Matt T. Yourst                    yourst at peptidal.com
>  Peptidal Research Inc., Co-Founder and Lead Architect
> -------------------------------------------------------
> _______________________________________________
> PTLsim-devel mailing list
> PTLsim-devel at ptlsim.org
> https://ptlsim.org/mailman/listinfo/ptlsim-devel



More information about the PTLsim-devel mailing list