Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Compiler warnings again



Bart Schaefer wrote:

> ../../../zsh-3.1.5/Src/Zle/compctl.c: In function `comp_setunset':
> ../../../zsh-3.1.5/Src/Zle/compctl.c:2312: warning: integer overflow in expression
> ../../../zsh-3.1.5/Src/Zle/compctl.c:2313: warning: integer overflow in expression

...never seen such a warning. But the reason is clear: the code uses
bit-masks to make the special parameters visible or not and an
expression like `(1<<num)-1' for `all parameters'. And the number of
parameters (including the `compstate' keys) has just reached
31. Ahem. If we add one more, I'll have to think about some other way, 
but for now, I hope the thing below keeps the compiler quiet. Right?

Bye
 Sven

diff -u os/Zle/comp.h Src/Zle/comp.h
--- os/Zle/comp.h	Mon Mar 29 11:49:31 1999
+++ Src/Zle/comp.h	Tue Mar 30 09:09:54 1999
@@ -309,4 +309,4 @@
 
 #define CP_NUM              31
 
-#define CP_ALLMASK    ((1 << CP_NUM) - 1)
+#define CP_ALLMASK    ((int) ((((unsigned int) 1) << CP_NUM) - 1))

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author