You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Compiling the codebase with -Waddress-of-packed-member produces multiple errors at build time:
error: taking address of packed member 'bmpih' of class or structure 'BMP_HEADER' may result in an unaligned pointer value [-Werror,-Waddress-of-packed-member]
compression = convertOnBigEnd32(bmpih->biCompression);
Taking the address of a packed member is dangerous since the reduced alignment of the pointee is lost. This can lead to memory alignment faults in some architectures if the pointer value is dereferenced.
The text was updated successfully, but these errors were encountered:
I know that this approach is in general unsafe. However, for BMP it's a simple approach that works on all platforms tested and has been extensively fuzzed. Besides being simple, I'm following "if it isn't broken, don't 'fix' it".
If you'd like to redo the code to avoid the compiler warning, have at it :-)
Compiling the codebase with
-Waddress-of-packed-member
produces multiple errors at build time:Taking the address of a packed member is dangerous since the reduced alignment of the pointee is lost. This can lead to memory alignment faults in some architectures if the pointer value is dereferenced.
The text was updated successfully, but these errors were encountered: