Re-introduced bugs by merging s3 and s4 libraries :-((

Derrell Lipman derrell.lipman at unwireduniverse.com
Sun Mar 8 01:31:12 GMT 2009


On Tue, Mar 3, 2009 at 7:35 AM, Volker Lendecke
<Volker.Lendecke at sernet.de>wrote:

> On Tue, Mar 03, 2009 at 07:08:50AM -0500, Derrell Lipman wrote:
> > > With your merge of convert_string_talloc you re-introduced a
> > > bug that we got rid of in S3 long ago: convert_string_talloc
> > > and others now take a void ** as destination pointer. This
> > > is not portable C.
> > >
> >
> > Volker, can you point me to the non-portability issues you've seen with
> > void**? It is easy to misuse void*, for example by assigning a function
> > pointer to it (that's illegal in C), but if void* is used properly then I
> > believe that void** should be portable. I'm really interested in where
> you
> > saw problems.
>
> void** as such is not the problem, it is void** as a
> function argument. You might want to look at the gcc manpage
> for the optimization switch -fstrict-aliasing. This is why I
> always ask people to compile with -O3, this reveals tons of
> warnings like the "dereferencing type-punned pointer will
> break strict-aliasing rules" one that this bug
> re-introduced.


I've done some research on this. There is no problem passing a void** to a
function which then puts a void* into the address pointed to by that
parameter. There is (theoretically) a pointer truncation problem if some
type _other than_ void* is assigned to the dereferenced parameter. Here's a
great article describing the (theoretical and fairly unlikely to occur in
real life) possibility that pointer truncation could occur. Search for the
reply by Chris Torek in the message thread:

  http://www.cpptalk.net/incrementing-a-void-pointer-legal-c99-vt52168.html

Derrell


More information about the samba-technical mailing list