Bug #60910 Some MySQL source code assumes the char data-type is signed.
Submitted: 18 Apr 2011 20:57 Modified: 22 Jan 2014 14:16
Reporter: Paul Green (OCA) Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:5.1.48, 5.6.x OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution

[18 Apr 2011 20:57] Paul Green
Description:
Some MySQL source code assumes the C/C++ "char" data type is signed, yet the Makefiles do not append the -fsigned-char option when using gcc.

For compatibility with other, older C compilers on the Stratus VOS operating system, our port of gcc defaults to unsigned chars.  We tracked down a failure in the main.outfile_loaddata self-test to some code in sql/sql_load.cc, in the READ_INFO::terminator subroutine, that fails when MySQL is built using unsigned characters. When we added the -fsigned-char option, the problems cleared up. We did not attempt to discover the exact problem with the code in READ_INFO::terminator; we took the easier route and changed the compilation options.

An earlier port of MySQL 5.0.75 to the same operating system and same version of gcc did not exhibit this erroneous behavior.

I have verified that the READ_INFO::terminator subroutine in sql_load.cc is unchanged in MySQL 5.6.2-m5.  I have not tried building MySQL 5.6.2-m5 to see if this issue is otherwise corrected; hence, I have tagged this bug report against 5.1.48. I took a peek at the CMake files distributed with 5.6.2-m5, but I don't see any references to -fsigned-char, so I rather suspect that this issue still exists in the current version.

For the record, this problem arose using GCC 3.4.6 on Stratus OpenVOS Release 17.1.

How to repeat:
You should be able to reproduce this issue by adding the -funsigned-char option to CFLAGS and CXXFLAGS.

Suggested fix:
I solved my problem by adding -fsigned-char to CFLAGS and CXXFLAGS. But I would prefer that MySQL not have any code in it that depends upon the signed quality of chars.

I have not supplied a patch, because I made changes to our build environment, rather than to any files in MySQL.
[14 Jun 2011 14:39] Valeriy Kravchuk
Even in current mysql-trunk we see:

macbook-pro:mysql-trunk openxs$ grep -rn signed-char *
cmd-line-utils/readline/configure.in:198:*s390*) LOCAL_CFLAGS=-fsigned-char ;;

and nothing else related to signed-char.
[22 Jan 2014 14:16] Ståle Deraas
This bug was fixed by the resolution to bug#59905