[FFmpeg-devel] [PATCH] fix 'warning: dereferencing type-punned pointer will break strict-aliasing rules' warning

Michael Niedermayer michaelni
Wed Mar 5 15:37:55 CET 2008


On Thu, Mar 06, 2008 at 01:11:38AM +1100, mark cox wrote:
> On Wed, Mar 5, 2008 at 11:27 PM, Michael Niedermayer <michaelni at gmx.at>
> wrote:
> 
> > On Wed, Mar 05, 2008 at 08:08:54PM +0800, Zuxy Meng wrote:
> > > Hi,
> > >
> > > 2008/3/5, Michael Niedermayer <michaelni at gmx.at>:
> > > > On Wed, Mar 05, 2008 at 12:51:04PM +0100, Michael Niedermayer wrote:
> > > > > On Wed, Mar 05, 2008 at 09:47:26PM +1100, mark cox wrote:
> > > > > > Here is a patch to fix the 'warning: dereferencing type-punned
> > pointer will
> > > > > > break strict-aliasing rules' warning.
> > > > >
> > > > > patch rejected
> > > >
> > > > Just to clarify even though it should be clear to every C programmer.
> > > > The warnings point to bugs, the bugs are not fixed by this patch.
> > >
> > > Someone willing to tell me the history about the "declared as uint64_t
> > > and cast to short" thing? Looks to me as a workaround for some
> > > compiler bug.
> >
> > Yes, old versions of gcc (dont ask which i dunno) ignored align attributes
> > for stack variables entirely, but they did align uint64_t to 8 bytes even
> > when it was on the stack (given that the stack was properly aligned).
> >
> > [...]
> >
> 
> What would be the correct way to fix this then? or is it unfixable while we
> still support old gcc versions?

one of:
* -fno-strict-aliasing + benchmarks proofing it doesnt slow things down
  (also dont forget that restrict can be usefull if theres a slowdown)
* live with the warnings
* find a clean fix with union, iam not sure if this can be done cleanly
  though.
* find out which gcc versions are affected and start a vote about dropping
  support for them, though i will vote against droping support for 2.95
* fix gcc and convince gnu to release a 2.95.4 or .5 or what the last official
  one +1 was (this still would likely need us to drop gcc 3.? support though)

Anyway this isnt easy and you could end up trying a few pathes and see
patches being rejected due to being messy ...

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080305/f355af5a/attachment.pgp>



More information about the ffmpeg-devel mailing list