Bug #56522 Compiler warnings in mysys/lf_hash.c
Submitted: 2 Sep 2010 22:47 Modified: 5 Oct 2010 11:29
Reporter: Marc Alff Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Compiling Severity:S1 (Critical)
Version:5.5-bugfixing OS:Any
Assigned to: Marc Alff CPU Architecture:Any
Triage: Triaged: D3 (Medium)

[2 Sep 2010 22:47] Marc Alff
Description:
Build warnings in mysql-5.5-bugfixing, host linux x86_64 werror

cc1: warnings being treated as errors
/export/home/pb2/build/sb_0-2232514-1283391604.79/mysql-5.5.7-m3/mysys/lf_hash.c: In function 'lfind':
/export/home/pb2/build/sb_0-2232514-1283391604.79/mysql-5.5.7-m3/mysys/lf_hash.c:125: warning: dereferencing type-punned pointer will break strict-aliasing rules
/export/home/pb2/build/sb_0-2232514-1283391604.79/mysql-5.5.7-m3/mysys/lf_hash.c: In function 'linsert':
/export/home/pb2/build/sb_0-2232514-1283391604.79/mysql-5.5.7-m3/mysys/lf_hash.c:171: warning: dereferencing type-punned pointer will break strict-aliasing rules
/export/home/pb2/build/sb_0-2232514-1283391604.79/mysql-5.5.7-m3/mysys/lf_hash.c: In function 'ldelete':
/export/home/pb2/build/sb_0-2232514-1283391604.79/mysql-5.5.7-m3/mysys/lf_hash.c:218: warning: dereferencing type-punned pointer will break strict-aliasing rules /export/home/pb2/build/sb_0-2232514-1283391604.79/mysql-5.5.7-m3/mysys/lf_hash.c:219: warning: dereferencing type-punned pointer will break strict-aliasing rules /export/home/pb2/build/sb_0-2232514-1283391604.79/mysql-5.5.7-m3/mysys/lf_hash.c:224: warning: dereferencing type-punned pointer will break strict-aliasing rules
/export/home/pb2/build/sb_0-2232514-1283391604.79/mysql-5.5.7-m3/mysys/lf_hash.c: In function 'initialize_bucket':
/export/home/pb2/build/sb_0-2232514-1283391604.79/mysql-5.5.7-m3/mysys/lf_hash.c:493: warning: dereferencing type-punned pointer will break strict-aliasing rules
gmake[2]: *** [mysys/CMakeFiles/mysys.dir/lf_hash.c.o] Error 1 gmake[2]: *** Waiting for unfinished jobs.... gmake[1]: *** [mysys/CMakeFiles/mysys.dir/all] Error 2 gmake: *** [all] Error 2 

How to repeat:
Build with gcc, -Wstrict-alias=2 or 3, -Wall, -Werror

See the build failures in build logs

Suggested fix:
N/A
[3 Sep 2010 0:01] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/117471

3203 Marc Alff	2010-09-02
      Bug#56522 Compiler warnings in mysys/lf_hash.c
      
      Before this fix, the file mysys/lf_hash.c would build with compiler
      warnings, such as "dereferencing type-punned pointer might break
      strict-aliasing rules".
      
      For GCC in particular, gcc 4.3.2 would generate warnings
      when compiled with -Wstrict-aliasing=2,
      and no warnings with -Wstrict-aliasing=3
      
      This fix simplifies the code to avoid complex constructs,
      and clarifies type casting.
      
      With the fix, the build is now clean for both
      -Wstrict-aliasing=2
      -Wstrict-aliasing=3
      
      While all warnings for all compilers / platforms / compiling options
      may not be fixed, this fix already improves the situation,
      as well as the readability of the code.
[21 Oct 2010 11:51] Davi Arnaut
I ended up disabling strict aliasing optimization for release builds http://lists.mysql.com/commits/120381/. So this bug is not very urgent, but we should eventually work towards fixing it. The best approach is to rework the atomic API so it does not require the current amount unsafe type casts.
[21 Oct 2010 11:54] Davi Arnaut
The correct link is: http://lists.mysql.com/commits/120381