[physfs] Re: more warnings

Dennis Schridde devurandom at gmx.net
Wed Mar 12 07:13:23 EDT 2008


Am Sonntag, 9. März 2008 12:06:06 schrieb Dennis Schridde:
> Am Sonntag, 9. März 2008 03:49:27 schrieb Ryan C. Gordon:
> > > I did not get very far, but attached my patch anyway.
> > > Hope someone can take it further.
> > > (It includes the pointer signing patch from above.)
> >
> > The pointer signing patch is committed, svn revision #930.
> >
> > I think gcc will disable strict aliasing rules if you cast something to
> > a (char *) first (the theory being that lots of legacy code breaks if
> > you can't rely on that), so it should probably fix the type-punning
> > warnings, too...
> >
> > So can you tell me if this fixes it?
>
> That "fixes" it...
> The patch I attached does that and marks it with a big fat warning, since I
> think one should not rely on such hidden triggers.
I think I've finally fixed it without a hack. :)
I am using the GCC 3.3+ "may_alias" attribute to create a new variant of 
FARPROC which may alias with any type, just like char*.
(FARPROC, because that is what GetProcAddress() returns.)

I would advise that the __attribute__((__may_alias__)) be guarded like 
WZ_DECL_MAY_ALIAS does in 
http://svn.gna.org/svn/warzone/trunk/lib/framework/wzglobal.h

--Dennis
-------------- next part --------------
A non-text attachment was scrubbed...
Name: no_type_punning.patch
Type: text/x-diff
Size: 1488 bytes
Desc: not available
URL: <http://icculus.org/pipermail/physfs/attachments/20080312/9af36fb5/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://icculus.org/pipermail/physfs/attachments/20080312/9af36fb5/attachment.pgp>


More information about the physfs mailing list