home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.gdb.bug
- Path: sparky!uunet!cis.ohio-state.edu!la.tce.COM!pierre
- From: pierre@la.tce.COM (Pierre Willard)
- Subject: cast integers into pointers
- Message-ID: <9209030218.AA21593@_la.tce.com>
- Sender: gnulists@ai.mit.edu
- Reply-To: pierre@la.tce.com
- Organization: GNUs Not Usenet
- Distribution: gnu
- Date: Thu, 3 Sep 1992 02:18:52 GMT
- Approved: bug-gdb@prep.ai.mit.edu
- Lines: 33
-
- I found a problem in gdb-4.5 on systems where integers and
- pointers are NOT the same size.
-
- (gdb) p (void*) 5
- Invalid cast.
- (gdb) p (void*) 500000
- $1 = (void *) 0x7a120
- (gdb) p (void*) (long) 5
- $2 = (void *) 0x5
- (gdb)
-
- A possible fix is the following : at the end of value_cast function
- (in valops.c) do :
-
- {
- /* Always accept a cast of an integer into a pointer,
- even when the sizes are not equals !
- */
- if (code1 == TYPE_CODE_PTR && scalar)
- return value_from_longest (type, value_as_pointer (arg2));
-
- error ("Invalid cast.");
- return 0;
- }
-
- Important: I also noticed that in value_cast(), in case pointers
- and integers are the SAME size, value_as_pointer() is NOT called
- to transform the value into a pointer, which is NOT very clean...
-
- Let me know your comments.
- Regards
- Pierre Willard
-
-