[patch] Compile failures on amd64/gcc 4.0

Mickael Marchand marchand at kde.org
Sun Jan 23 22:37:43 GMT 2005


Thiago Macieira wrote:
> Mickael Marchand wrote:
> 
>>+      int bits = (ptrdiff_t)syms->modsyms[res]-1;
> 
> 
> Why don't you declare those variables as ptrdiff_t as well?
> 
> gcc may not display a warning about loss of precision, but it will happen 
> nonetheless.

hmm ok,

like this ?

Cheers,
Mik
-------------- next part --------------
Index: keytrans.cpp
===================================================================
RCS file: /home/kde/kdebase/konsole/konsole/keytrans.cpp,v
retrieving revision 1.48
diff -u -3 -p -r1.48 keytrans.cpp
--- keytrans.cpp	22 Sep 2004 20:02:16 -0000	1.48
+++ keytrans.cpp	23 Jan 2005 22:36:02 -0000
@@ -372,7 +372,7 @@ Loop:
 //printf("line %3d: ",startofsym);
     getSymbol(); assertSyntax(sym == SYMName, "Name expected")
     assertSyntax(syms->keysyms[res], "Unknown key name")
-    int key = (int)syms->keysyms[res]-1;
+    ptrdiff_t key = (ptrdiff_t)syms->keysyms[res]-1;
 //printf(" key %s (%04x)",res.latin1(),(int)syms->keysyms[res]-1);
     getSymbol(); // + - :
     int mode = 0;
@@ -384,7 +384,7 @@ Loop:
       // mode name
       assertSyntax(sym == SYMName, "Name expected")
       assertSyntax(syms->modsyms[res], "Unknown mode name")
-      int bits = (int)syms->modsyms[res]-1;
+      ptrdiff_t bits = (ptrdiff_t)syms->modsyms[res]-1;
       if (mask & (1 << bits))
       {
         fprintf(stderr,"%s(%d,%d): mode name used multible times.\n",path.ascii(),slinno,scolno);
@@ -401,11 +401,11 @@ Loop:
     getSymbol();
     // string or command
     assertSyntax(sym == SYMName || sym == SYMString,"Command or string expected")
-    int cmd = 0;
+    ptrdiff_t cmd = 0;
     if (sym == SYMName)
     {
       assertSyntax(syms->oprsyms[res], "Unknown operator name")
-      cmd = (int)syms->oprsyms[res]-1;
+      cmd = (ptrdiff_t)syms->oprsyms[res]-1;
 //printf(": do %s(%d)",res.latin1(),(int)syms->oprsyms[res]-1);
     }
     if (sym == SYMString)


More information about the kde-core-devel mailing list