[FFmpeg-devel] [PATCH V3 3/3] libavfilter: add filter dnn_detect for object detection

Nicolas George george at nsup.org
Sun Mar 28 20:58:25 EEST 2021


Andreas Rheinhardt (12021-03-01):
> 3. As you probably guessed from the last part of 2., I don't think that
> casting avoids the possibility of undefined behaviour* (because this
> conversion is done automatically anyway); but it might very well protect
> the code from aggressively optimizing compilers.

Possibly not.

On the other hand, there is no doubt that (type *)((char *)structp +
offsetof(field)) would be valid, since:

- (char *)structp + offsetof(field) is really a pointer on field, so it
  has proper alignment for type;

- the entire array is within a memory block obtained through malloc().

So, worst case scenario, we can use this construct to work around a
compiler that does stupid optimizations.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20210328/e7ee8018/attachment.sig>


More information about the ffmpeg-devel mailing list