linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Pointer arithmetic error
@ 2008-06-26 23:40 David Given
  2008-06-26 23:51 ` Chris Li
  0 siblings, 1 reply; 20+ messages in thread
From: David Given @ 2008-06-26 23:40 UTC (permalink / raw)
  To: linux-sparse

[-- Attachment #1: Type: text/plain, Size: 855 bytes --]

I've just found what I think is a bug. In evaluate_ptr_add(), in
evaluate.c, are the following lines:

	/* Get the size of whatever the pointer points to */
	multiply = base->bit_size >> 3;

This divides the bit size by 8 to get the size in bytes. However, this
doesn't take into account that bits_in_char might not be 8. I think this
should actually be:

	/* Get the size of whatever the pointer points to */
	multiply = base->bit_size / bits_in_char;

(This now produces the right result on my non-8-bit-char 'platform'.)

-- 
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2008-06-29 12:20 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-26 23:40 Pointer arithmetic error David Given
2008-06-26 23:51 ` Chris Li
2008-06-27  0:17   ` David Given
2008-06-27  9:00     ` Christopher Li
2008-06-27  9:49     ` Bernd Petrovitsch
2008-06-27 10:55       ` David Given
2008-06-27 11:20         ` Bernd Petrovitsch
2008-06-27 14:03           ` David Given
2008-06-27 14:45             ` Bernd Petrovitsch
2008-06-27 15:45               ` David Given
2008-06-27 18:01                 ` Christopher Li
2008-06-27 23:32                   ` David Given
2008-06-28  0:17                     ` Christopher Li
2008-06-28  0:23                       ` David Given
2008-06-29  0:10                       ` David Given
2008-06-28  0:29                     ` Josh Triplett
2008-06-29  0:13                     ` Tommy Thorn
     [not found]                     ` <48658B28.6010301@numba-tu.com>
2008-06-29  0:30                       ` David Given
2008-06-29  0:38                         ` Tommy Thorn
2008-06-29 12:19                   ` Bernd Petrovitsch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).