Bug #42733 | Type-punning warnings when compiling MySQL -- strict aliasing violations. | ||
---|---|---|---|
Submitted: | 10 Feb 2009 15:37 | Modified: | 29 Jan 2014 0:48 |
Reporter: | Vasil Dimov | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Compiling | Severity: | S3 (Non-critical) |
Version: | 5.1.31 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[10 Feb 2009 15:37]
Vasil Dimov
[10 Feb 2009 15: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 2009 8:20]
Valeriy Kravchuk
Verified with gcc 4.2.4 on Ubuntu with -O3 only (no warnings like this with -O2 for me).
[11 Feb 2009 8: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
[27 Aug 2009 22: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
[27 Aug 2009 22: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
[27 Aug 2009 22: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.
[3 Jun 2010 3:48]
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/110043 3411 Davi Arnaut 2010-06-03 Bug#42733: type-punning warnings when compiling MySQL with -O2/-O3 -Wall and gcc 4.x Essentially, the problem is that large parts of the server were developed in simpler times (last decades, pre C99 standard) when strict aliasing rules and optimizations were rare to non-existent. Thus, when compiling the server with a modern compiler that uses strict aliasing rules to perform optimizations, there are several places that might break (undefined behavior) depending on how the compiler optimizes. As evinced by some recent bugs, GCC does a somewhat good of job misoptimizing such code, but on the other hand also gives warnings about suspicious code. One problem is that the warnings aren't always accurate, yet we can't afford to just shut them off as we might miss real cases. False-positive cases are aggravated mostly by casts that are likely to trigger undefined behavior. The solution is to start a cleanup process focused on fixing and reducing the amount of strict-aliasing related warnings produced by GCC and others compilers. A good deal of noise reduction can be achieved by just removing useless casts that are product of historical cruft. @ client/mysql.cc Remove now-unnecessary casts. Break up large strings. @ client/mysql_upgrade.c Remove now-unnecessary casts. @ client/mysqladmin.cc Remove now-unnecessary casts. Break up large strings. @ client/mysqlbinlog.cc Remove now-unnecessary casts. @ client/mysqlcheck.c Remove now-unnecessary casts. @ client/mysqldump.c Remove now-unnecessary casts. @ client/mysqlimport.c Remove now-unnecessary casts. @ client/mysqlshow.c Remove now-unnecessary casts. @ client/mysqlslap.c Remove now-unnecessary casts. @ client/mysqltest.cc Remove now-unnecessary casts. @ extra/comp_err.c Remove now-unnecessary casts. @ extra/my_print_defaults.c Remove now-unnecessary casts. Break up large strings. @ extra/mysql_waitpid.c Remove now-unnecessary casts. @ extra/perror.c Remove now-unnecessary casts. @ extra/resolve_stack_dump.c Remove now-unnecessary casts. @ extra/resolveip.c Remove now-unnecessary casts. @ include/my_getopt.h Use a void pointer type as the opaque type to avoid problems with type incompatibility -- GCC issues warnings when the type name is not type compatible with a operand. As a side bonus, a explicit cast won't be necessary anymore. @ include/sslopt-longopts.h Remove now-unnecessary casts. Break up large strings. @ mysys/my_getopt.c Update opaque type. @ server-tools/instance-manager/options.cc Remove now-unnecessary casts. @ sql/mysqld.cc Remove now-unnecessary casts. Break up large strings. Update mysql_getopt_value prototype (the old prototype was different from the definition anyway). @ sql/sql_plugin.cc The type of a pointer to a function must be compatible with the pointed-to function type, otherwise the behavior is undefined. @ sql/table.cc The variable buf pointer to pointer to pointer to constant char could improperly alias a incompatible type in call to fix_type_ pointers. Since this was actually dead code, it is simply removed. @ sql/unireg.cc Remove call to get_form_pos. When creating a new FRM file, the position of a form is always known (0). @ storage/archive/archive_reader.c Remove now-unnecessary casts. @ storage/myisam/ft_nlq_search.c The value of a object of type int could be accessed via the type float, thus violating strict aliasing rules. Use a union for type punning. @ storage/myisam/fulltext.h Use the union type-punning technique to access a object via two incompatible types. Although not strictly standard conformant, the technique is often recommended (ie by GCC) and is quite portable. @ storage/myisam/mi_test1.c Remove now-unnecessary casts. @ storage/myisam/myisam_ftdump.c The value of a object of type int could be accessed via the type float, thus violating strict aliasing rules. Use a union for type punning. @ storage/myisam/myisamchk.c Remove now-unnecessary casts. @ storage/myisam/myisamlog.c A pointer to char was used to alias a pointer to pointer to unsigned char, thus violating strict aliasing rules. @ storage/myisam/myisampack.c Remove now-unnecessary casts. @ tests/mysql_client_test.c Remove now-unnecessary casts.
[4 Jun 2010 13:33]
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/110244 3416 Davi Arnaut 2010-06-04 Bug#42733: type-punning warnings when compiling MySQL with -O2/-O3 -Wall and gcc 4.x Essentially, the problem is that large parts of the server were developed in simpler times (last decades, pre C99 standard) when strict aliasing and compilers supporting such optimizations were rare to non-existent. Thus, when compiling the server with a modern compiler that uses strict aliasing rules to perform optimizations, there are several places in the code that might trigger undefined behavior. As evinced by some recent bugs, GCC does a somewhat good of job misoptimizing such code, but on the other hand also gives warnings about suspicious code. One problem is that the warnings aren't always accurate, yet we can't afford to just shut them off as we might miss real cases. False-positive cases are aggravated mostly by casts that are likely to trigger undefined behavior. The solution is to start a cleanup process focused on fixing and reducing the amount of strict-aliasing related warnings produced by GCC and others compilers. A good deal of noise reduction can be achieved by just removing useless casts that are product of historical cruft and are likely to trigger undefined behavior if deferenced. @ client/mysql.cc Remove now-unnecessary casts. Break up large strings. @ client/mysql_upgrade.c Remove now-unnecessary casts. @ client/mysqladmin.cc Remove now-unnecessary casts. Break up large strings. @ client/mysqlbinlog.cc Remove now-unnecessary casts. @ client/mysqlcheck.c Remove now-unnecessary casts. @ client/mysqldump.c Remove now-unnecessary casts. @ client/mysqlimport.c Remove now-unnecessary casts. @ client/mysqlshow.c Remove now-unnecessary casts. @ client/mysqlslap.c Remove now-unnecessary casts. @ client/mysqltest.cc Remove now-unnecessary casts. @ extra/comp_err.c Remove now-unnecessary casts. @ extra/my_print_defaults.c Remove now-unnecessary casts. Break up large strings. @ extra/mysql_waitpid.c Remove now-unnecessary casts. @ extra/perror.c Remove now-unnecessary casts. @ extra/resolve_stack_dump.c Remove now-unnecessary casts. @ extra/resolveip.c Remove now-unnecessary casts. @ include/my_getopt.h Use a void pointer type as the opaque type to avoid problems with type incompatibility -- GCC issues warnings when the type name is not type compatible with a operand. As a side bonus, a explicit cast won't be necessary anymore. @ include/sslopt-longopts.h Remove now-unnecessary casts. Break up large strings. @ mysys/my_getopt.c Update opaque type. @ server-tools/instance-manager/options.cc Remove now-unnecessary casts. @ sql/mysqld.cc Remove now-unnecessary casts. Break up large strings. Update mysql_getopt_value prototype (the old prototype was different from the definition anyway). @ sql/sql_plugin.cc The type of a pointer to a function must be compatible with the pointed-to function type, otherwise the behavior is undefined. @ sql/table.cc The variable buf pointer to pointer to pointer to constant char could improperly alias a incompatible type in call to fix_type_ pointers. Since this was actually dead code, it is simply removed. @ sql/unireg.cc Remove call to get_form_pos. When creating a new FRM file, the position of a form is always known (0). @ storage/archive/archive_reader.c Remove now-unnecessary casts. @ storage/myisam/ft_nlq_search.c The value of a object of type int could be accessed via the type float, thus violating strict aliasing rules. Use a union for type punning. @ storage/myisam/fulltext.h Use the union type-punning technique to access a object via two incompatible types. Although not strictly standard conformant, the technique is often recommended (ie by GCC) and is quite portable. @ storage/myisam/mi_test1.c Remove now-unnecessary casts. @ storage/myisam/myisam_ftdump.c The value of a object of type int could be accessed via the type float, thus violating strict aliasing rules. Use a union for type punning. @ storage/myisam/myisamchk.c Remove now-unnecessary casts. @ storage/myisam/myisamlog.c A pointer to char was used to alias a pointer to pointer to unsigned char, thus violating strict aliasing rules. @ storage/myisam/myisampack.c Remove now-unnecessary casts. @ tests/mysql_client_test.c Remove now-unnecessary casts.
[4 Jun 2010 14:25]
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/110246 3417 Davi Arnaut 2010-06-04 Bug#42733: Type-punning warnings when compiling MySQL -- strict aliasing violations. One somewhat major source of strict-aliasing violations and related warnings is the SQL_LIST structure. For example, consider its member function `link_in_list` which takes a pointer to pointer of type T (any type) as a pointer to pointer to unsigned char. Dereferencing this pointer, which is done to reset the next field, violates strict-aliasing rules and might cause problems for surrounding code that uses the next field of the object being added to the list. The solution is to use templates to parametrize the SQL_LIST structure in order to deference the pointers with compatible types. As a side bonus, it becomes possible to remove quite a few casts related to acessing data members of SQL_LIST. @ sql/handler.h Use the appropriate template type argument. @ sql/item.cc Remove now-unnecessary cast. @ sql/item_subselect.cc Remove now-unnecessary casts. @ sql/item_sum.cc Use the appropriate template type argument. Remove now-unnecessary cast. @ sql/mysql_priv.h Move SQL_LIST structure to sql_list.h Use the appropriate template type argument. @ sql/sp.cc Remove now-unnecessary casts. @ sql/sql_delete.cc Use the appropriate template type argument. Remove now-unnecessary casts. @ sql/sql_derived.cc Remove now-unnecessary casts. @ sql/sql_lex.cc Remove now-unnecessary casts. @ sql/sql_lex.h SQL_LIST now takes a template type argument which must match the type of the elements of the list. Use forward declaration when the type is not available, it is used in pointers anyway. @ sql/sql_list.h Rename SQL_LIST to SQL_I_List. The template parameter is the type of object that is stored in the list. @ sql/sql_olap.cc Remove now-unnecessary casts. @ sql/sql_parse.cc Remove now-unnecessary casts. @ sql/sql_prepare.cc Remove now-unnecessary casts. @ sql/sql_select.cc Remove now-unnecessary casts. @ sql/sql_show.cc Remove now-unnecessary casts. @ sql/sql_table.cc Remove now-unnecessary casts. @ sql/sql_trigger.cc Remove now-unnecessary casts. @ sql/sql_union.cc Remove now-unnecessary casts. @ sql/sql_update.cc Remove now-unnecessary casts. @ sql/sql_view.cc Remove now-unnecessary casts. @ sql/sql_yacc.yy Remove now-unnecessary casts. @ storage/myisammrg/ha_myisammrg.cc Remove now-unnecessary casts.
[4 Jun 2010 20:28]
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/110286 3416 Davi Arnaut 2010-06-04 Bug#42733: Type-punning warnings when compiling MySQL -- strict aliasing violations. Essentially, the problem is that large parts of the server were developed in simpler times (last decades, pre C99 standard) when strict aliasing and compilers supporting such optimizations were rare to non-existent. Thus, when compiling the server with a modern compiler that uses strict aliasing rules to perform optimizations, there are several places in the code that might trigger undefined behavior. As evinced by some recent bugs, GCC does a somewhat good of job misoptimizing such code, but on the other hand also gives warnings about suspicious code. One problem is that the warnings aren't always accurate, yet we can't afford to just shut them off as we might miss real cases. False-positive cases are aggravated mostly by casts that are likely to trigger undefined behavior. The solution is to start a cleanup process focused on fixing and reducing the amount of strict-aliasing related warnings produced by GCC and others compilers. A good deal of noise reduction can be achieved by just removing useless casts that are product of historical cruft and are likely to trigger undefined behavior if deferenced. @ client/mysql.cc Remove now-unnecessary casts. Break up large strings. @ client/mysql_upgrade.c Remove now-unnecessary casts. @ client/mysqladmin.cc Remove now-unnecessary casts. Break up large strings. @ client/mysqlbinlog.cc Remove now-unnecessary casts. @ client/mysqlcheck.c Remove now-unnecessary casts. @ client/mysqldump.c Remove now-unnecessary casts. @ client/mysqlimport.c Remove now-unnecessary casts. @ client/mysqlshow.c Remove now-unnecessary casts. @ client/mysqlslap.c Remove now-unnecessary casts. @ client/mysqltest.cc Remove now-unnecessary casts. @ extra/comp_err.c Remove now-unnecessary casts. @ extra/my_print_defaults.c Remove now-unnecessary casts. Break up large strings. @ extra/mysql_waitpid.c Remove now-unnecessary casts. @ extra/perror.c Remove now-unnecessary casts. @ extra/resolve_stack_dump.c Remove now-unnecessary casts. @ extra/resolveip.c Remove now-unnecessary casts. @ include/my_getopt.h Use a void pointer type as the opaque type to avoid problems with type incompatibility -- GCC issues warnings when the type name is not type compatible with a operand. As a side bonus, a explicit cast won't be necessary anymore. @ include/sslopt-longopts.h Remove now-unnecessary casts. Break up large strings. @ mysys/my_getopt.c Update opaque type and introduce a type definition for the argument to my_getopt_register_get_addr. @ server-tools/instance-manager/options.cc Remove now-unnecessary casts. @ sql/mysqld.cc Remove now-unnecessary casts. Break up large strings. Update mysql_getopt_value prototype (the old prototype was different from the definition anyway). @ sql/sql_plugin.cc The type of a pointer to a function must be compatible with the pointed-to function type, otherwise the behavior is undefined. @ sql/table.cc The variable buf pointer to pointer to pointer to constant char could improperly alias a incompatible type in call to fix_type_ pointers. Since this was actually dead code, it is simply removed. @ sql/unireg.cc Remove call to get_form_pos. When creating a new FRM file, the position of a form is always known (0). @ storage/archive/archive_reader.c Remove now-unnecessary casts. @ storage/myisam/ft_nlq_search.c The value of a object of type int could be accessed via the type float, thus violating strict aliasing rules. Use a union for type punning. @ storage/myisam/fulltext.h Use the union type-punning technique to access a object via two incompatible types. Although not strictly standard conformant, the technique is often recommended (ie by GCC) and is quite portable. @ storage/myisam/mi_test1.c Remove now-unnecessary casts. @ storage/myisam/myisam_ftdump.c The value of a object of type int could be accessed via the type float, thus violating strict aliasing rules. Use a union for type punning. @ storage/myisam/myisamchk.c Remove now-unnecessary casts. @ storage/myisam/myisamlog.c A pointer to char was used to alias a pointer to pointer to unsigned char, thus violating strict aliasing rules. @ storage/myisam/myisampack.c Remove now-unnecessary casts. @ tests/mysql_client_test.c Remove now-unnecessary casts.
[8 Jun 2010 19:17]
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/110546 3421 Davi Arnaut 2010-06-08 Bug#42733: Type-punning warnings when compiling MySQL -- strict aliasing violations. Essentially, the problem is that large parts of the server were developed in simpler times (last decades, pre C99 standard) when strict aliasing and compilers supporting such optimizations were rare to non-existent. Thus, when compiling the server with a modern compiler that uses strict aliasing rules to perform optimizations, there are several places in the code that might trigger undefined behavior. As evinced by some recent bugs, GCC does a somewhat good of job misoptimizing such code, but on the other hand also gives warnings about suspicious code. One problem is that the warnings aren't always accurate, yet we can't afford to just shut them off as we might miss real cases. False-positive cases are aggravated mostly by casts that are likely to trigger undefined behavior. The solution is to start a cleanup process focused on fixing and reducing the amount of strict-aliasing related warnings produced by GCC and others compilers. A good deal of noise reduction can be achieved by just removing useless casts that are product of historical cruft and are likely to trigger undefined behavior if deferenced. @ client/mysql.cc Remove now-unnecessary casts. Break up large strings. @ client/mysql_upgrade.c Remove now-unnecessary casts. @ client/mysqladmin.cc Remove now-unnecessary casts. Break up large strings. @ client/mysqlbinlog.cc Remove now-unnecessary casts. @ client/mysqlcheck.c Remove now-unnecessary casts. @ client/mysqldump.c Remove now-unnecessary casts. @ client/mysqlimport.c Remove now-unnecessary casts. @ client/mysqlshow.c Remove now-unnecessary casts. @ client/mysqlslap.c Remove now-unnecessary casts. @ client/mysqltest.cc Remove now-unnecessary casts. @ extra/comp_err.c Remove now-unnecessary casts. @ extra/my_print_defaults.c Remove now-unnecessary casts. Break up large strings. @ extra/mysql_waitpid.c Remove now-unnecessary casts. @ extra/perror.c Remove now-unnecessary casts. @ extra/resolve_stack_dump.c Remove now-unnecessary casts. @ extra/resolveip.c Remove now-unnecessary casts. @ include/my_getopt.h Use a void pointer type as the opaque type to avoid problems with type incompatibility -- GCC issues warnings when the type name is not type compatible with a operand. As a side bonus, a explicit cast won't be necessary anymore. @ include/sslopt-longopts.h Remove now-unnecessary casts. Break up large strings. @ mysys/my_getopt.c Update opaque type and introduce a type definition for the argument to my_getopt_register_get_addr. @ server-tools/instance-manager/options.cc Remove now-unnecessary casts. @ sql/mysqld.cc Remove now-unnecessary casts. Break up large strings. Update mysql_getopt_value prototype (the old prototype was different from the definition anyway). @ sql/sql_plugin.cc The type of a pointer to a function must be compatible with the pointed-to function type, otherwise the behavior is undefined. @ sql/table.cc The variable buf pointer to pointer to pointer to constant char could improperly alias a incompatible type in call to fix_type_ pointers. Since this was actually dead code, it is simply removed. @ sql/unireg.cc Remove call to get_form_pos. The code creates a new FRM file which is always truncated and writes the form position as 0. Hence, no need to retrieve it, we now for sure it is 0. @ storage/archive/archive_reader.c Remove now-unnecessary casts. @ storage/myisam/ft_nlq_search.c The value of a object of type int could be accessed via the type float, thus violating strict aliasing rules. Use a union for type punning. @ storage/myisam/fulltext.h Use the union type-punning technique to access a object via two incompatible types. Although not strictly standard conformant, the technique is often recommended (ie by GCC) and is quite portable. @ storage/myisam/mi_test1.c Remove now-unnecessary casts. @ storage/myisam/myisam_ftdump.c The value of a object of type int could be accessed via the type float, thus violating strict aliasing rules. Use a union for type punning. @ storage/myisam/myisamchk.c Remove now-unnecessary casts. @ storage/myisam/myisamlog.c A pointer to char was used to alias a pointer to pointer to unsigned char, thus violating strict aliasing rules. @ storage/myisam/myisampack.c Remove now-unnecessary casts. @ tests/mysql_client_test.c Remove now-unnecessary casts.
[8 Jun 2010 19:37]
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/110549 3421 Davi Arnaut 2010-06-08 Bug#42733: Type-punning warnings when compiling MySQL -- strict aliasing violations. Essentially, the problem is that large parts of the server were developed in simpler times (last decades, pre C99 standard) when strict aliasing and compilers supporting such optimizations were rare to non-existent. Thus, when compiling the server with a modern compiler that uses strict aliasing rules to perform optimizations, there are several places in the code that might trigger undefined behavior. As evinced by some recent bugs, GCC does a somewhat good of job misoptimizing such code, but on the other hand also gives warnings about suspicious code. One problem is that the warnings aren't always accurate, yet we can't afford to just shut them off as we might miss real cases. False-positive cases are aggravated mostly by casts that are likely to trigger undefined behavior. The solution is to start a cleanup process focused on fixing and reducing the amount of strict-aliasing related warnings produced by GCC and others compilers. A good deal of noise reduction can be achieved by just removing useless casts that are product of historical cruft and are likely to trigger undefined behavior if deferenced. @ client/mysql.cc Remove now-unnecessary casts. Break up large strings. @ client/mysql_upgrade.c Remove now-unnecessary casts. @ client/mysqladmin.cc Remove now-unnecessary casts. Break up large strings. @ client/mysqlbinlog.cc Remove now-unnecessary casts. @ client/mysqlcheck.c Remove now-unnecessary casts. @ client/mysqldump.c Remove now-unnecessary casts. @ client/mysqlimport.c Remove now-unnecessary casts. @ client/mysqlshow.c Remove now-unnecessary casts. @ client/mysqlslap.c Remove now-unnecessary casts. @ client/mysqltest.cc Remove now-unnecessary casts. @ extra/comp_err.c Remove now-unnecessary casts. @ extra/my_print_defaults.c Remove now-unnecessary casts. Break up large strings. @ extra/mysql_waitpid.c Remove now-unnecessary casts. @ extra/perror.c Remove now-unnecessary casts. @ extra/resolve_stack_dump.c Remove now-unnecessary casts. @ extra/resolveip.c Remove now-unnecessary casts. @ include/my_getopt.h Use a void pointer type as the opaque type to avoid problems with type incompatibility -- GCC issues warnings when the type name is not type compatible with a operand. As a side bonus, a explicit cast won't be necessary anymore. @ include/sslopt-longopts.h Remove now-unnecessary casts. Break up large strings. @ mysys/my_getopt.c Update opaque type and introduce a type definition for the argument to my_getopt_register_get_addr. @ server-tools/instance-manager/options.cc Remove now-unnecessary casts. @ sql/mysqld.cc Remove now-unnecessary casts. Break up large strings. Update mysql_getopt_value prototype (the old prototype was different from the definition anyway). @ sql/sql_plugin.cc The type of a pointer to a function must be compatible with the pointed-to function type, otherwise the behavior is undefined. @ sql/table.cc The variable buf pointer to pointer to pointer to constant char could improperly alias a incompatible type in call to fix_type_ pointers. Since this was actually dead code, it is simply removed. @ sql/unireg.cc Remove call to get_form_pos. The code creates a new FRM file which is always truncated and writes the form position as 0. Hence, no need to retrieve it, we now for sure it is 0. @ storage/archive/archive_reader.c Remove now-unnecessary casts. @ storage/myisam/ft_nlq_search.c Read weight directly from the buffer. @ storage/myisam/fulltext.h Add explanation about the type duality of a key buffer. Add accessor macro to retrieve a FT float value. @ storage/myisam/mi_test1.c Remove now-unnecessary casts. @ storage/myisam/myisam_ftdump.c Read weight directly from the buffer. @ storage/myisam/myisamchk.c Remove now-unnecessary casts. @ storage/myisam/myisamlog.c A pointer to char was used to alias a pointer to pointer to unsigned char, thus violating strict aliasing rules. @ storage/myisam/myisampack.c Remove now-unnecessary casts. @ strings/decimal.c Remove aliasing violation, printing the value is enough for debugging purposes. @ tests/mysql_client_test.c Remove now-unnecessary casts.
[11 Jun 2010 16:12]
Davi Arnaut
Queued to mysql-5.1-bugteam and up. Reseting to Verified as there still some issues left.
[17 Jun 2010 6:15]
Bugs System
Pushed into 5.5.5-m3 (revid:alexey.kopytov@sun.com-20100615145247-8bj0vmuqlotbqsn9) (version source revid:davi.arnaut@sun.com-20100611013049-9b3xahkzymlev9xn) (merge vers: 5.5.5-m3) (pib:16)
[17 Jun 2010 6:18]
Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100615150216-cubqoyn1fj9b6a2p) (version source revid:alik@sun.com-20100615081608-4ieksdrefamsw3v9) (pib:16)
[5 Jul 2010 20:51]
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/112919 3459 Davi Arnaut 2010-07-05 Bug#42733: Type-punning warnings when compiling MySQL -- strict aliasing violations. Another rather noisy violation of strict aliasing rules is the spatial code which makes use of stack-based memory (of type Geometry_buffer) to provide placement for Geometry objects. Although a placement new is allowed to dynamically change the type of a object, the object returned by the new placement was being ignored and the original stack-based object was being casted to the new type, thus violating strict aliasing rules. The solution is to reorganize the code so that the object returned by the new placement is used instead of casting the original object. Also, to ensure that the stack-based object is properly aligned with respect to the objects it provides placement for, a set of compiler-dependent macros and types are introduced so that the alignment of objects can be inquired and specified. @ include/Makefile.am Add new header. @ include/my_compiler.h Add header to house compiler-dependent features. Use compiler/version to detect available features at build time instead of configure time in order to avoid common pitfalls in autoconf-based checks (such as attributes being ignored by certain compilers). Add macros to inquire and set alignment. Add my_aligned_storage which is similar to the C++0x aligned_storage type, which provides a POD-type suitable for use as uninitialized storage for any object. Use partial template specialization due to historical weakness of using attributes with template arguments. @ include/my_global.h Remove now-unnecessary macros. @ sql/spatial.cc Make object creation functions return the object whose type was dynamically changed by the new placement. Move static method from the header in order to avoid having to access a forward declaration. @ sql/spatial.h Object creation callbacks now take a array of chars as the storage area. Move create_by_typeid to a source file as to not access the forward declaration of Geometry_buffer. Ensure that Geometry_buffer is properly aligned. @ sql/sql_show.cc Use newly added aligned storage helper.
[14 Jul 2010 12:27]
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/113565 3480 Davi Arnaut 2010-07-14 Bug#42733: Type-punning warnings when compiling MySQL -- strict aliasing violations. Another rather noisy violation of strict aliasing rules is the spatial code which makes use of stack-based memory (of type Geometry_buffer) to provide placement for Geometry objects. Although a placement new is allowed to dynamically change the type of a object, the object returned by the new placement was being ignored and the original stack-based object was being casted to the new type, thus violating strict aliasing rules. The solution is to reorganize the code so that the object returned by the new placement is used instead of casting the original object. Also, to ensure that the stack-based object is properly aligned with respect to the objects it provides placement for, a set of compiler-dependent macros and types are introduced so that the alignment of objects can be inquired and specified. @ include/Makefile.am Add new header. @ include/my_compiler.h Add new header. @ include/my_global.h Remove now-unnecessary macros. @ sql/spatial.cc Make object creation functions return the object whose type was dynamically changed by the new placement. Move static method from the header in order to avoid having to access a forward declaration. @ sql/spatial.h Object creation callbacks now take a array of chars as the storage area. Move create_by_typeid to a source file as to not access the forward declaration of Geometry_buffer. Ensure that Geometry_buffer is properly aligned. @ sql/sql_show.cc Use newly added aligned storage helper.
[14 Jul 2010 14:21]
Davi Arnaut
Last patch queued to mysql-5.1-bugteam.
[14 Jul 2010 19:40]
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/113628 3484 Davi Arnaut 2010-07-14 Bug#42733: Type-punning warnings when compiling MySQL -- strict aliasing violations. Post-merge fix: include my_compiler.h before my_attribute.h as the latter will undef __attribute__ if the compiler is not GCC. Based on the compiler version, in my_compiler.h we know for sure whether the aligned attribute is supported. Furthermore, undefining attribute might cause bugs if some system header uses it. @ include/my_compiler.h Drop aligned attribute support from Sun Studio C++ compiler as its not clear exactly which version of it supports the attribute.
[15 Jul 2010 19:29]
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/113705 3124 Davi Arnaut 2010-07-15 Bug#42733: Type-punning warnings when compiling MySQL -- strict aliasing violations. Silence bogus aliasing warning through a pointer indirection. Also, no need to check the return of a placement new.
[19 Jul 2010 14:38]
Bugs System
Pushed into 5.1.49 (revid:build@mysql.com-20100719143034-omcma40sblwmay3x) (version source revid:davi.arnaut@sun.com-20100610204522-no7qrofcyp4mjvmt) (merge vers: 5.1.48) (pib:16)
[23 Jul 2010 12:25]
Bugs System
Pushed into mysql-trunk 5.5.6-m3 (revid:alik@sun.com-20100723121820-jryu2fuw3pc53q9w) (version source revid:vasil.dimov@oracle.com-20100531152341-x2d4hma644icamh1) (merge vers: 5.5.5-m3) (pib:18)
[23 Jul 2010 12:32]
Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100723121929-90e9zemk3jkr2ocy) (version source revid:vasil.dimov@oracle.com-20100531152341-x2d4hma644icamh1) (pib:18)
[4 Aug 2010 7:50]
Bugs System
Pushed into mysql-trunk 5.5.6-m3 (revid:alik@sun.com-20100731131027-1n61gseejyxsqk5d) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 7:55]
Bugs System
Pushed into mysql-trunk 5.5.6-m3 (revid:alik@sun.com-20100731131027-1n61gseejyxsqk5d) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 7:56]
Bugs System
Pushed into mysql-trunk 5.5.6-m3 (revid:alik@sun.com-20100731131027-1n61gseejyxsqk5d) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 7:57]
Bugs System
Pushed into mysql-trunk 5.5.6-m3 (revid:alik@sun.com-20100731131027-1n61gseejyxsqk5d) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 7:58]
Bugs System
Pushed into mysql-trunk 5.5.6-m3 (revid:alik@sun.com-20100731131027-1n61gseejyxsqk5d) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 7:59]
Bugs System
Pushed into mysql-trunk 5.5.6-m3 (revid:alik@sun.com-20100731131027-1n61gseejyxsqk5d) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 8:00]
Bugs System
Pushed into mysql-trunk 5.5.6-m3 (revid:alik@sun.com-20100731131027-1n61gseejyxsqk5d) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 8:07]
Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804080001-bny5271e65xo34ig) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 8:13]
Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804080001-bny5271e65xo34ig) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 8:14]
Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804080001-bny5271e65xo34ig) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 8:15]
Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804080001-bny5271e65xo34ig) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 8:16]
Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804080001-bny5271e65xo34ig) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 8:17]
Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804080001-bny5271e65xo34ig) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 8:23]
Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804081533-c1d3rbipo9e8rt1s) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:18)
[4 Aug 2010 9:00]
Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@ibmvm-20100804081533-c1d3rbipo9e8rt1s) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (merge vers: 5.1.49) (pib:20)
[4 Aug 2010 9:03]
Bugs System
Pushed into mysql-next-mr (revid:alik@ibmvm-20100804081630-ntapn8bf9pko9vj3) (version source revid:marko.makela@oracle.com-20100621094008-o9fa153s3f09merw) (pib:20)
[19 Aug 2010 15:42]
Bugs System
Pushed into mysql-5.1 5.1.51 (revid:build@mysql.com-20100819151858-muaaor6jojb5ouzj) (version source revid:build@mysql.com-20100819151858-muaaor6jojb5ouzj) (merge vers: 5.1.51) (pib:20)
[8 Oct 2010 13:31]
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/120381 3225 Davi Arnaut 2010-10-08 Bug#42733: Type-punning warnings when compiling MySQL -- strict aliasing violations. Due to the extent of aliasing violations in the MySQL source code, at this time it is safer to disable strict aliasing related optimizations in release builds. As of this patch, only GCC enables strict aliasing by default. Hence, use the -fno-strict-aliasing option to disable the aliasing rules. @ cmake/build_configurations/mysql_release.cmake Add -fno-strict-aliasing to release builds.
[14 Oct 2010 8:32]
Bugs System
Pushed into mysql-5.1-telco-7.0 5.1.51-ndb-7.0.20 (revid:martin.skold@mysql.com-20101014082627-jrmy9xbfbtrebw3c) (version source revid:martin.skold@mysql.com-20101014082627-jrmy9xbfbtrebw3c) (merge vers: 5.1.51-ndb-7.0.20) (pib:21)
[14 Oct 2010 8:47]
Bugs System
Pushed into mysql-5.1-telco-6.3 5.1.51-ndb-6.3.39 (revid:martin.skold@mysql.com-20101014083757-5qo48b86d69zjvzj) (version source revid:martin.skold@mysql.com-20101014083757-5qo48b86d69zjvzj) (merge vers: 5.1.51-ndb-6.3.39) (pib:21)
[14 Oct 2010 9:02]
Bugs System
Pushed into mysql-5.1-telco-6.2 5.1.51-ndb-6.2.19 (revid:martin.skold@mysql.com-20101014084420-y54ecj85j5we27oa) (version source revid:martin.skold@mysql.com-20101014084420-y54ecj85j5we27oa) (merge vers: 5.1.51-ndb-6.2.19) (pib:21)
[9 Nov 2010 19:45]
Bugs System
Pushed into mysql-5.5 5.5.7-rc (revid:sunanda.menon@sun.com-20101109182959-otkxq8vo2dcd13la) (version source revid:sunanda.menon@sun.com-20101109182959-otkxq8vo2dcd13la) (merge vers: 5.5.7-rc) (pib:21)
[13 Nov 2010 16:06]
Bugs System
Pushed into mysql-trunk 5.6.99-m5 (revid:alexander.nozdrin@oracle.com-20101113155825-czmva9kg4n31anmu) (version source revid:alexander.nozdrin@oracle.com-20101113152450-2zzcm50e7i4j35v7) (merge vers: 5.6.1-m4) (pib:21)
[13 Nov 2010 16:34]
Bugs System
Pushed into mysql-next-mr (revid:alexander.nozdrin@oracle.com-20101113160336-atmtmfb3mzm4pz4i) (version source revid:vasil.dimov@oracle.com-20100629074804-359l9m9gniauxr94) (pib:21)
[29 Jan 2014 0:48]
Paul DuBois
Noted in 5.5.7 changelog. Many type-punning warnings during compilation were silenced.