Bug#326451: jlint: FTBFS (amd64): cast from 'const void*' to 'int' loses precision

2005-09-09 Thread Kurt Roeckx
On Fri, Sep 09, 2005 at 09:16:04AM +0530, Ganesan Rajagopal wrote:
 Kurt Roeckx wrote:
 
 It looks like the patch was only partially applied?
 
 Anyway, please do not cast a pointer to either an int or a long.
 Cast it to an intptr_t if you have to, but you should be able to
 avoid that too.
 Thanks. But how do you give a printf format argument for intptr_t?

You shouldn't.  You passed an integer to it, so extract an
integer from the va_list.  You could cast it back to an int if
you want to.

If you really want to print an intptr_t, inttypes.h defines a
PRIdPTR you can use to print an intptr_t, something like:
printf(% PRIdPTR \n, ptr);


Kurt



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#326451: jlint: FTBFS (amd64): cast from 'const void*' to 'int' loses precision

2005-09-09 Thread Ganesan Rajagopal

Kurt Roeckx wrote:


On Fri, Sep 09, 2005 at 09:16:04AM +0530, Ganesan Rajagopal wrote:
 


Thanks. But how do you give a printf format argument for intptr_t?
   



You shouldn't.  You passed an integer to it, so extract an
integer from the va_list.  You could cast it back to an int if
you want to.
 

Oh we already agreed about that :-). I was curious how to handle 
intptr_t portably in

a printf. Thanks for the info.

Ganesan


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#326451: jlint: FTBFS (amd64): cast from 'const void*' to 'int' loses precision

2005-09-08 Thread Kurt Roeckx
found 326451 3.0-3
thanks

Hi,

3.0-3 is still failing to build:
jlint.cc: In function 'void format_message(int, const utf_string, int, 
__va_list_tag*)':
jlint.cc:240: warning: field precision should have type 'int', but argument 3 
has type 'long int'
jlint.cc:264: error: cast from 'const void*' to 'int' loses precision


It looks like the patch was only partially applied?

Anyway, please do not cast a pointer to either an int or a long.
Cast it to an intptr_t if you have to, but you should be able to
avoid that too.

It seems to be using stdargs.  It really should just call
va_arg() with the right type instead of always using a void *.
If you always call va_arg for a void *, this means whenever you
pass something to it, you'll always have to cast it to a void *.

PS: The TODO file says:

* (1) Make code 64 bit clean by adding more type casts. E.g.
  void *p;
  int i;
  p = (void *) (ptrword) i;
  where ptrword is derived from a ./configure script.

ptrword should just be intptr_t.  And he shouldn't be using it.


PS: It would be nice if you could run the testsuite (in
tests.tar.bz2) and make the build fail if it found any errors.


Kurt



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#326451: jlint: FTBFS (amd64): cast from 'const void*' to 'int' loses precision

2005-09-08 Thread Ganesan Rajagopal

Kurt Roeckx wrote:


found 326451 3.0-3
thanks
 

I had noted the problem myself and already uploaded 3.0-4. 3.0-4 has 
already been autobuilt successfully for ia64 and alpha.


http://buildd.debian.org/build.php?arch=pkg=jlint


It looks like the patch was only partially applied?

Anyway, please do not cast a pointer to either an int or a long.
Cast it to an intptr_t if you have to, but you should be able to
avoid that too.
 


Thanks. But how do you give a printf format argument for intptr_t?


It seems to be using stdargs.  It really should just call
va_arg() with the right type instead of always using a void *.
If you always call va_arg for a void *, this means whenever you
pass something to it, you'll always have to cast it to a void *.
 


I agree. I have no idea why upstream took this approach.


PS: It would be nice if you could run the testsuite (in
tests.tar.bz2) and make the build fail if it found any errors.
 


I'll take a look.

Ganesan


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#326451: jlint: FTBFS (amd64): cast from 'const void*' to 'int' loses precision

2005-09-07 Thread Andreas Jochens
reopen 326451
retitle 326451 FTBFS (amd64): cast from 'const void*' to 'int' loses precision
thanks

Hello,

thanks for fixing the Build-Depends. 

However, the patch contained a second part which was not applied.
When building 'jlint' on amd64/unstable, I still get the following error:

jlint.cc: In function 'void format_message(int, const utf_string, int, 
__va_list_tag*)':
jlint.cc:153: error: cast from 'const void*' to 'int' loses precision
jlint.cc:228: error: cast from 'const void*' to 'int' loses precision
jlint.cc:240: warning: field precision should have type 'int', but argument 3 
has type 'long int'
jlint.cc:264: error: cast from 'const void*' to 'int' loses precision
jlint.cc: In function 'bool parse_class_file(byte*)':
jlint.cc:431: warning: unused variable 'desc_index'
jlint.cc:496: warning: unused variable 'max_stack'
jlint.cc:325: warning: unused variable 'minor_version'
jlint.cc:327: warning: unused variable 'major_version'
make[1]: *** [jlint.o] Error 1
make[1]: Leaving directory `/jlint-3.0'
make: *** [build-arch-stamp] Error 2

With the attached patch 'jlint' can be compiled
on amd64 using gcc-4.0.

Regards
Andreas Jochens

diff -urN ../tmp-orig/jlint-3.0/jlint.cc ./jlint.cc
--- ../tmp-orig/jlint-3.0/jlint.cc  2004-01-14 16:23:20.0 +
+++ ./jlint.cc  2005-09-03 11:38:32.0 +
@@ -137,7 +137,7 @@
 
 void format_message(int code, utf_string const file, int line, __VALIST ap)
 {
-  static int loop_id;
+  static long loop_id;
   static message_node *first, *last;
   static char* compound_message;
   const void* parameter[MAX_MSG_PARAMETERS];
@@ -150,7 +150,7 @@
 if (compound_message != NULL
  ((loop_id != 0 
   ((code != msg_loop  code != msg_sync_loop)
- || (int)parameter[2] != loop_id))
+ || (long)parameter[2] != loop_id))
 || (loop_id == 0  code != msg_wait_path)))
   {
 if (!message_node::find(compound_message)) { 
@@ -225,7 +225,7 @@
name.as_asciz()); 
 break;
   case 'd': // integer
-dst += sprintf(dst, %d, (int)parameter[index]);  
+dst += sprintf(dst, %ld, (long)parameter[index]);  
 break;
   default:
 assert(false/*bad message parameter format*/);
@@ -261,7 +261,7 @@
   compound_message = strdup(his_buf);
   first = last = new message_node(msg_buf);
   if (code != msg_wait) { 
-loop_id = (int)parameter[2];
+loop_id = (long)parameter[2];
   }
 } else if (!message_node::find(his_buf)) { 
   fprintf(stdout, %s\n, msg_buf);


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]