Bug #59906 5.5 debug builds broken by extra/comp_err.c
Submitted: 2 Feb 2011 22:38 Modified: 2 Mar 2011 3:44
Reporter: Mark Callaghan Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:5.5 OS:Any
Assigned to: Tor Didriksen CPU Architecture:Any
Tags: debug
Triage: Triaged: D4 (Minor)

[2 Feb 2011 22:38] Mark Callaghan
cmake -DWITH_DEBUG builds for 5.5.8 fail for me because of a compiler warning about a potentially unused variable in extra/comp_err.c

How to repeat:
system uses gcc 4.1.2, centos 5.2, x86-64

cmake . \
-DBUILD_CONFIG=mysql_release \

output is

cc1: warnings being treated as errors
/s/bld/558orig/extra/comp_err.c: In function ‘create_header_files’:
/s/bld/558orig/extra/comp_err.c:222: warning: ‘er_last’ may be used uninitialized in this function
make[2]: *** [extra/CMakeFiles/comp_err.dir/comp_err.c.o] Error 1
make[1]: *** [extra/CMakeFiles/comp_err.dir/all] Error 2
make: *** [all] Error 2

Suggested fix:
This might be a kludge, but I just want my builds

diff --git a/extra/comp_err.c b/extra/comp_err.c
index 4c40e70..8b7ddbf 100644
--- a/extra/comp_err.c
+++ b/extra/comp_err.c
@@ -219,7 +219,7 @@ static void print_escaped_string(FILE *f, const char *str)
 static int create_header_files(struct errors *error_head)
-  uint er_last;
+  uint er_last=0;
   FILE *er_definef, *sql_statef, *er_namef;
   struct errors *tmp_error;
   struct message *er_msg;
[3 Feb 2011 9:01] Valeriy Kravchuk
I can not repeat this problem with current mysql-5.5 tree on 32-bit Ubuntu 10.04 using:

gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3

for whatever reason. But code in extra/comp_err.c is still the same:

static int create_header_files(struct errors *error_head)
  uint er_last;
  FILE *er_definef, *sql_statef, *er_namef;
  struct errors *tmp_error;
  struct message *er_msg;
  const char *er_text;


and, theoretically, LINT_INIT macro defined in include/my_global.h as follows:

  Deprecated workaround for false-positive uninitialized variables
  warnings. Those should be silenced using tool-specific heuristics.

  Enabled by default for g++ due to the bug referenced below.
#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || \
    (defined(__GNUC__) && defined(__cplusplus))
#define LINT_INIT(var) var= 0
#define LINT_INIT(var)

should take care of initialization... but I think your suggested change in code will do that even better.

So, let's say this is verified by code review.
[2 Mar 2011 3:44] Paul Dubois
Noted in 5.5.11, 5.6.2 changelogs.

On some systems, debug builds of comp_err.c could fail due to an
uninitialized variable. 

CHANGESET - http://lists.mysql.com/commits/131432