[vlc-devel] [PATCH] Embed vlc_object_t for subtyping (strict aliasing)
rom1v at videolabs.io
Mon Jun 11 11:29:38 CEST 2018
On Sun, Jun 10, 2018 at 09:26:04PM +0300, Rémi Denis-Courmont wrote:
> Le sunnuntaina 10. kesäkuuta 2018, 20.34.40 EEST Romain Vimont a écrit :
> > With strict aliasing enabled, it is undefined to access a field after a
> > cast to an unrelated type, even if both types declare the same field.
> Nevertheless the minimalistic type safety of VLC_OBJECT() has saved many asses
> many times, and I don't want to ditch it without a replacement that is not at
> least as safe. So not a plain dumb unchecked cast.
I posted a v2 which checks only in debug mode. It adds an unused "bool
obj" in vlc_object_t just to make the (unused) _Generic branch valid, to
make the compiler happy.
More information about the vlc-devel