[Zlib-devel] A few compiler warnings with 1.2.2.2

Gilles Vollant info at winimage.com
Sun Feb 6 17:08:09 EST 2005


Your patch did not solves the problem, I continue to get this warning


warning C4334: '<<' : result of 32-bit shift implicitly converted to 64 bits
(was 64-bit shift intended?) 

I tried
  zmemcpy(window, state->window, (uInt)(((uInt)1U) << state->wbits));
And obtain also the warning

Just for info, here is the documentation about this warning



Compiler Warning (level 3) C4334  
 
'operator' : result of 32-bit shift implicitly converted to 64 bits (was
64-bit shift intended?)

The result of 32-bit shift was implicitly converted to 64-bits, and the
compiler suspects that a 64-bit shift was intended. To resolve this warning,
either use 64-bit shift, or explicitly cast the shift result to 64-bit.

 Example 
The following sample generates C4334.

 Copy Code 
// C4334.cpp
// compile with: /W3 /c
void SetBit(unsigned __int64 *p, int i) 
{
   *p |= (1 << i);   // C4334
   *p |= (1i64 << i);   // OK
}
 


-----Original Message-----
From: Mark Adler [mailto:madler at alumni.caltech.edu] 
Sent: Sunday, February 06, 2005 10:50 PM
To: zlib-devel at zlib.net
Subject: Re: [Zlib-devel] A few compiler warnings with 1.2.2.2

On Feb 6, 2005, at 1:33 PM, Gilles Vollant wrote:
>  !         zmemcpy(window, state->window, 1U << state->wbits);
>
> Give a warning
>
> But
> {
> uInt startlog = 1;
> zmemcpy(window, state->window, startlog << state->wbits); } Give no 
> warning

Remarkable.  Microsoft must have a team of highly-paid geniuses that do
nothing but come up with new ways to drive people crazy.

Ok, let me know if the patch below helps.

mark


*** ../zlib-1.2.2.2/inflate.c   Fri Nov 12 21:49:43 2004
--- inflate.c   Sun Feb  6 13:45:48 2005
***************
*** 1338,1344 ****
       copy->distcode = copy->codes + (state->distcode - state->codes);
       copy->next = copy->codes + (state->next - state->codes);
       if (window != Z_NULL)
!         zmemcpy(window, state->window, 1U << state->wbits);
       copy->window = window;
       dest->state = (voidpf)copy;
       return Z_OK;
--- 1338,1344 ----
       copy->distcode = copy->codes + (state->distcode - state->codes);
       copy->next = copy->codes + (state->next - state->codes);
       if (window != Z_NULL)
!         zmemcpy(window, state->window, (uInt)(1U << state->wbits));
       copy->window = window;
       dest->state = (voidpf)copy;
       return Z_OK;


*** ../zlib-1.2.2.2/inftrees.c  Sun Oct 31 09:54:30 2004
--- inftrees.c  Sun Feb  6 13:45:27 2005
***************
*** 262,268 ****
                   drop = root;

               /* increment past last table */
!             next += 1U << curr;

               /* determine length of next table */
               curr = len - drop;
--- 262,268 ----
                   drop = root;

               /* increment past last table */
!             next += (unsigned)(1U << curr);

               /* determine length of next table */
               curr = len - drop;


_______________________________________________
Zlib-devel mailing list
Zlib-devel at zlib.net
http://madler.net/mailman/listinfo/zlib-devel_madler.net







More information about the Zlib-devel mailing list