This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

left shift count >= width of type


Hi,

When using gcc3 for mingw, I always get a "left shift count >= width of type" error when including a specific boost header, boost-1_39/boost/date_time/filetime_functions.hpp, at line 101, which looks like:

        const uint64_t c1 = 27111902UL;
        const uint64_t c2 = 3577643008UL; // issues warning without 'UL'
        const uint64_t shift = (c1 << 32) + c2;


where uint64_t is an unsigned long long.



interestingly, if I add the above code in a simple function, no warning occurs. but, if I add the above code into a function template (as it is in the boost include file), I do get the warning. so something like:



template< typename T > void foo() { /* shift is difference between 1970-Jan-01 & 1601-Jan-01 * in 100-nanosecond intervals */ const uint64_t c1 = 27111902UL; const uint64_t c2 = 3577643008UL; // issues warning without 'UL' const uint64_t shift = (c1 << 32) + c2; }


will result in a warning, without the template, it does not.


what is the reason for this warning, and how can it be averted?


Akos



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]