Closed Exactlywb closed 2 years ago
Fixed by commit 0ae7969c1243a0fc048b34cc7b24c54acc257029 (There was a typo in the previous git comment...)
Thanks! But what do you think about strict aliasing rule violation in this part of code?
The -fstrict-aliasing option is enabled at levels -O2, -O3, -Os. -Wstrict-aliasing This option is only active when -fstrict-aliasing is active. It warns about code that might break the strict aliasing rules that the compiler is using for optimization. The warning does not catch all cases, but does attempt to catch the more common pitfalls. It is included in -Wall. It is equivalent to -Wstrict-aliasing=3
gcc 12.1.1 doesn't warn about aliasing problem, so I don't think there is a real problem...
Thank you for the quick response!
Hi! I've built testdisk using
-O2 -Werror=array-bounds
on gcc 11.2 and got an error:Here I've seen two problems. Let's see truncated code example:
The first problem is there's only 512 bytes for the
struct ext2_super_block
? As I understand, Superblock is exactly 1024 bytes in length. And the second one is that similar memory casts violates strict aliasing rule. So I think it's better to usememcpy
instead of to the structure pointer cast. The same strict aliasing violence may be found hereI hope my report will be useful for you.
Thanks