home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / gnu / gdb / bug / 1017 < prev    next >
Encoding:
Text File  |  1992-09-02  |  1.2 KB  |  47 lines

  1. Newsgroups: gnu.gdb.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!la.tce.COM!pierre
  3. From: pierre@la.tce.COM (Pierre Willard)
  4. Subject: cast integers into pointers
  5. Message-ID: <9209030218.AA21593@_la.tce.com>
  6. Sender: gnulists@ai.mit.edu
  7. Reply-To: pierre@la.tce.com
  8. Organization: GNUs Not Usenet
  9. Distribution: gnu
  10. Date: Thu, 3 Sep 1992 02:18:52 GMT
  11. Approved: bug-gdb@prep.ai.mit.edu
  12. Lines: 33
  13.  
  14. I found a problem in gdb-4.5 on systems where integers and
  15. pointers are NOT the same size.
  16.  
  17. (gdb) p (void*) 5
  18. Invalid cast.
  19. (gdb) p (void*) 500000
  20. $1 = (void *) 0x7a120
  21. (gdb) p (void*) (long) 5
  22. $2 = (void *) 0x5
  23. (gdb) 
  24.  
  25. A possible fix is the following : at the end of value_cast function
  26. (in valops.c) do :
  27.  
  28.     {
  29.     /* Always accept a cast of an integer into a pointer,
  30.     even when the sizes are not equals !
  31.      */
  32.       if (code1 == TYPE_CODE_PTR && scalar)
  33.         return value_from_longest (type, value_as_pointer (arg2));    
  34.  
  35.       error ("Invalid cast.");
  36.       return 0;
  37.     }
  38.  
  39. Important: I also noticed that in value_cast(), in case pointers
  40. and integers are the SAME size, value_as_pointer() is NOT called
  41. to transform the value into a pointer, which is NOT very clean...
  42.  
  43. Let me know your comments.
  44. Regards
  45. Pierre Willard
  46.  
  47.