lkml.org 
[lkml]   [2004]   [Apr]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Linux 2.4.26-rc2
Eyal Lebedinsky wrote:
> Marcelo Tosatti wrote:
>
>> The void pointer case in here its being done math on without any
>> problem. What is the
>> problem with void pointer math
>
>
> There is a problem regarding the C standard. The semantics of 'void *'
> are well defined
> and only allow for limited use. Basically, you can cast any pointer to
> and from 'void *',
> but nothing else.
>
> Pointer math says that 'p+n' means "add to 'p' the value 'n*s' where 's'
> is the size
> on the element that 'p' points to". A 'void *' does not have a defined
> element size
> until it is cast. So, ANSI specifically does not allow any arithmetics
> on 'void *'.
>
> Some compilers are forgiving and will invent an element size of '1' and
> allow the
> math. We should not rely on such improper usage.


Void pointer arithmatic is an explicit gcc extension, and used
extensively throughout the kernel.

Jeff



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:02    [W:0.032 / U:0.716 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site