NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: toolchain/43234: lint warns about perfectly good casts
The following reply was made to PR toolchain/43234; it has been noted by GNATS.
From: Wolfgang Solfrank <Wolfgang%Solfrank.net@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc:
Subject: Re: toolchain/43234: lint warns about perfectly good casts
Date: Tue, 04 May 2010 16:09:52 +0200
Hi,
> Use lint -chapbxzFS per sys.mk. It says
>
> foo.c(12): warning: pointer casts may be troublesome [247]
Well, actually lint is perfectly correct in pointing out possible
trouble here.
I once worked on a 16 bit machine, where most addresses are
16 bit and point to 16 bit values, i.e., the machine has
65536 16 bit words or 128 kB of memory. In contrast to that,
byte pointers are also 16 bits, but address bytes, i.e. the
machine can only address the low 64 kB using character pointers.
Casting an int pointer to a character pointer shifts the 16 bits
one bit to the left, loosing the high bit (which poses trouble
if the original value was in the upper 64 kB.) Of course the
opposite cast shifts to the right, but you can't get the lost
bit back.
I've got no idea, why lint doesn't warn if you add the extra
cast through a void pointer.
Ciao,
Wolfgang
--
Wolfgang%Solfrank.net@localhost Wolfgang
Solfrank
Home |
Main Index |
Thread Index |
Old Index