Hi Florian,

On Wed, 2021-12-15 at 23:40 +0100, Florian Weimer via Elfutils-devel
wrote:
> * Mark Wielaard:
> 
> > This seems a wrong warning since we aren't accessing the field member
> > of the struct, but are taking the address of it. But we can do the
> > same by adding the field offsetof to the base address. Which doesn't
> > trigger a runtime error.
> 
> I think the warning is correct.  I believe it is motivated by the GCC
> optimizers using this to infer alignment of the original pointer.  It
> won't make a difference for this expression, but it can cause crashes
> elsewhere with strict-alignment targets.

I think that does make sense. I tweaked to commit message a bit before
pushing the commit to say:

  We aren't actually accessing the field member of the struct, but are
  taking the address of it. Which the compiler can take as a hint that
  the address is correctly aligned. But we can do the same by adding
  the field offsetof to the base address. Which doesn't trigger a
  runtime error.

Thanks,

Mark

Reply via email to