1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

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
dereferenced.
This commit is contained in:
Davi Arnaut
2010-06-10 17:16:43 -03:00
parent e3b4d33187
commit bb036c93b4
35 changed files with 1248 additions and 1111 deletions

View File

@ -971,7 +971,7 @@ int decimal2double(decimal_t *from, double *to)
*to= from->sign ? -result : result;
DBUG_PRINT("info", ("result: %f (%lx)", *to, *(ulong *)to));
DBUG_PRINT("info", ("result: %f", *to));
return E_DEC_OK;
}