| Bug #42733 | type-punning warnings when compiling MySQL with -O2/-O3 -Wall and gcc 4.x | ||
|---|---|---|---|
| Submitted: | 10 Feb 16:37 | Modified: | 11 Feb 9:20 |
| Reporter: | Vasil Dimov | ||
| Status: | Verified | ||
| Category: | Server: Compiling | Severity: | S3 (Non-critical) |
| Version: | 5.1.31 | OS: | Any |
| Assigned to: | Staale Smedseng | Target Version: | 5.1+ |
| Triage: | Triaged: D4 (Minor) | ||
[10 Feb 16:37]
Vasil Dimov
[10 Feb 16:42]
Vasil Dimov
To trigger this -O2 or -O3 and -Wall must be used and a gcc 4.x. I confirm that adding -fno-strict-aliasing to the compilation flags silences the warnings. Assigning to Kolbe because he says "It seems that the gcc 4.1 warnings have been repaired. If you believe otherwise, please show some examples. Thanks!" in Bug#22100, feel free to reassign.
[11 Feb 9:20]
Valeriy Kravchuk
Verified with gcc 4.2.4 on Ubuntu with -O3 only (no warnings like this with -O2 for me).
[11 Feb 9:37]
Valeriy Kravchuk
Here is the list of warnings: openxs@ubuntu:~/mysql-5.1.31$ make 2>&1 | tee /tmp/make.log | grep type-punning ha_example.cc:888: warning: type-punning to incomplete type might break strict-aliasing rules ha_example.cc:889: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8349: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8350: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8351: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8352: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8353: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8354: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8355: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8356: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8357: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8358: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8359: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8360: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8361: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8362: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8363: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8364: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8365: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8370: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8371: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8372: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8373: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8374: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8375: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8376: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8377: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8378: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8379: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8380: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8381: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8382: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8383: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8384: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8385: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8386: warning: type-punning to incomplete type might break strict-aliasing rules handler/ha_innodb.cc:8387: warning: type-punning to incomplete type might break strict-aliasing rules plugin_example.c:246: warning: type-punning to incomplete type might break strict-aliasing rules plugin_example.c:247: warning: type-punning to incomplete type might break strict-aliasing rules plugin_example.c:248: warning: type-punning to incomplete type might break strict-aliasing rules plugin_example.c:249: warning: type-punning to incomplete type might break strict-aliasing rules
[28 Aug 0:30]
Mark Callaghan
I get a ton of these using Centos 5, gcc 4.1.2, x86_64 and MySQL 5.0.84: g++ (GCC) 4.1.2 20071124 (Red Hat 4.1.2-42) The warnings are like: g++ -DMYSQL_SERVER -DDEFAULT_MYSQL_HOME="\"/data/5084\"" -DDATADIR="\"/data/5084/var\"" -DSHAREDIR="\"/data/5084/share/mysql\"" -DHAVE_CONFIG_H -I. -I../include -I../innobase/include -I../innobase/i nclude -I../include -I../include -I../regex -I. -O3 -DDBUG_OFF -fno-implicit-templates -fno-exceptions -fno-rtti -Wall -MT sql_parse.o -MD -MP -MF .deps/sql_parse.Tpo -c -o sql_parse.o sql_pa rse.cc sql_parse.cc: In function ‘bool dispatch_command(enum_server_command, THD*, char*, uint)’: sql_parse.cc:2066: warning: dereferencing type-punned pointer will break strict-aliasing rules sql_parse.cc: In function ‘bool mysql_new_select(LEX*, bool)’: sql_parse.cc:6287: warning: dereferencing type-punned pointer will break strict-aliasing rules sql_parse.cc: In function ‘bool add_proc_to_list(THD*, Item*)’: sql_parse.cc:6633: warning: dereferencing type-punned pointer will break strict-aliasing rules sql_parse.cc: In function ‘bool add_to_list(THD*, SQL_LIST&, Item*, bool)’: sql_parse.cc:6685: warning: dereferencing type-punned pointer will break strict-aliasing rules sql_parse.cc: In member function ‘virtual TABLE_LIST* st_select_lex::add_table_to_list(THD*, Table_ident*, LEX_STRING*, ulong, thr_lock_type, List<String>*, List<String>*, LEX_STRING*)’: sql_parse.cc:6846: warning: dereferencing type-punned pointer will break strict-aliasing rules sql_parse.cc: In member function ‘bool st_select_lex_unit::add_fake_select_lex(THD*)’: sql_parse.cc:7136: warning: dereferencing type-punned pointer will break strict-aliasing rules
[28 Aug 0:32]
Mark Callaghan
Using gcc -O2 instead of -O3 does not make them go away: g++ -DMYSQL_SERVER -DDEFAULT_MYSQL_HOME="\"/data/5084\"" -DDATADIR="\"/data/5084/var\"" -DSHAREDIR="\"/data/5084/share/mysql\"" -DHAVE_CONFIG_H -I. -I../include -I../innobase/include -I../innobase/i nclude -I../include -I../include -I../regex -I. -O2 -DDBUG_OFF -fno-implicit-templates -fno-exceptions -fno-rtti -Wall -MT mysqld.o -MD -MP -MF .deps/mysqld.Tpo -c -o mysqld.o mysqld.cc mysqld.cc:5065: warning: dereferencing type-punned pointer will break strict-aliasing rules mysqld.cc:5065: warning: dereferencing type-punned pointer will break strict-aliasing rules mysqld.cc:5079: warning: dereferencing type-punned pointer will break strict-aliasing rules mysqld.cc:5080: warning: dereferencing type-punned pointer will break strict-aliasing rules mysqld.cc:5084: warning: dereferencing type-punned pointer will break strict-aliasing rules
[28 Aug 0:36]
Davi Arnaut
The -Wall flag enables -Wstrict-aliasing, see gcc manual. The warning can be safely ignored for now, we are working towards revamping the the struct that leads to this warning.
