fahadshaikh05 / miniz

Automatically exported from code.google.com/p/miniz
0 stars 0 forks source link

Compiler warnings on strict aliasing #27

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. gcc -Wall -Werror -O2 miniz.c
2.
3.

What is the expected output? What do you see instead?
Expected output: Compiler errors due to no main().
Actual output:
Compiler errors due to type punning.
miniz.c: In function ‘tdefl_find_match’:
miniz.c:2270:3: error: dereferencing type-punned pointer will break 
strict-aliasing rules [-Werror=strict-aliasing]
miniz.c:2282:7: error: dereferencing type-punned pointer will break 
strict-aliasing rules [-Werror=strict-aliasing]
miniz.c:2282:7: error: dereferencing type-punned pointer will break 
strict-aliasing rules [-Werror=strict-aliasing]
miniz.c:2282:7: error: dereferencing type-punned pointer will break 
strict-aliasing rules [-Werror=strict-aliasing]
miniz.c:2294:7: error: dereferencing type-punned pointer will break 
strict-aliasing rules [-Werror=strict-aliasing]
miniz.c: In function ‘tdefl_compress_fast’:
miniz.c:2367:7: error: dereferencing type-punned pointer will break 
strict-aliasing rules [-Werror=strict-aliasing]

What version of the product are you using? On what operating system?
9.1.15, all MINIZ_NO_* enabled. Linux Mint 15, AMD64, GCC 4.7.3-1ubuntu1.

Please provide any additional information below.
Disabling warnings, optimization, or both, makes this go away.

Original issue reported on code.google.com by blub...@gmail.com on 24 Nov 2013 at 5:02

GoogleCodeExporter commented 9 years ago
I'll take a look at this in my latest devel version and see what I can do.

With gcc/clang I *always* compile with -fno-strict-aliasing, like the Linux 
kernel:
https://lkml.org/lkml/2003/2/26/158
http://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg01647.html

If you look at miniz's CMakeLists.txt, it uses -fno-strict-aliasing.

Original comment by richge...@gmail.com on 2 Dec 2013 at 3:06