[PATCH libdrm] xf86drm: fix aliasing violation

Grazvydas Ignotas notasas at gmail.com
Mon Dec 12 23:28:42 UTC 2016


On Mon, Dec 12, 2016 at 3:59 PM, Emil Velikov <emil.l.velikov at gmail.com> wrote:
> On 11 December 2016 at 18:03, Grazvydas Ignotas <notasas at gmail.com> wrote:
>> Just tell the compiler that drm_event will alias the char buffer,
>> so that it has no excuse to warn or generate bad code.
>>
> Afacit this patch [1] from Thierry should correctly address the issue, correct ?

>From what I've read, gcc's "strict aliasing" means that it's illegal
to access the same memory location using pointers of different types,
with only one exception - accessing an object of any type through a
char pointer. What is done here is the opposite - char array is read
as a struct, so according to that it's still wrong.

That said I haven't seen any compiler causing problems in this case,
and Thierry's solution indeed silences the warning, so I guess you can
take his patch if you prefer.

GraÅžvydas


More information about the dri-devel mailing list