|
-
November 30th, 2008, 05:09 PM
#1
shift count negative or too big, undefined behavior
Given:
Code:
typedef unsigned long long ulong_long_type ;
istream& istream::operator>>(
ulong_long_type& dest )
{
BGetter source( *this ) ;
ulong_long_type tmp = source.get() << 56 ;
tmp |= source.get() << 48 ;
tmp |= source.get() << 40 ;
tmp |= source.get() << 32 ;
tmp |= source.get() << 24 ;
tmp |= source.get() << 16 ;
tmp |= source.get() << 8 ;
tmp |= source.get() ;
return *this ;
}
During compilation I get warnings from Visual studio 2007 surrounding the left shift values 56, 48, 40 and 32, more specifically:
3>c:\sw_dev\msvc_2007-orcas\test\istream.h(158) : warning C4293: '<<' : shift count negative or too big, undefined behavior
3>c:\sw_dev\msvc_2007-orcas\test\istream.h(159) : warning C4293: '<<' : shift count negative or too big, undefined behavior
3>c:\sw_dev\msvc_2007-orcas\test\istream.h(160) : warning C4293: '<<' : shift count negative or too big, undefined behavior
3>c:\sw_dev\msvc_2007-orcas\test\istream.h(161) : warning C4293: '<<' : shift count negative or too big, undefined behavior
Of course I could ignore the warning but the claim of 'undefined behavior' is cause for concern. Thoughts.
Thanks in advance
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|