Bug #62196 Compile Error "Identifier not allowed in sizeof declarations" AIX 6.1 xlC 11
Submitted: 17 Aug 2011 16:18 Modified: 20 Feb 2012 19:32
Reporter: David Schroeder Email Updates:
Status: Unsupported Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:mysql-5.5.16 OS:IBM AIX (6.1 TL6)
Assigned to: CPU Architecture:Any
Tags: AIX xlC bchange.c my_global.h

[17 Aug 2011 16:18] David Schroeder
Description:
Compiling mysql 5.5.15 under AIX and xlc 11.1, I get the following error: 

xlc_r  -ma -O3 -qstrict -qoptimize=3 -qmaxmem=8192  -DHAVE_CONFIG_H -DDISABLE_MYSQL_THREAD_H -qthreaded -qalias=noansi -qhalt=e   -g -DENABLED_DEBUG_SYNC -I/opt/freeware/src/packages/BUILD/mysql-5.5.15/debug/include -I/opt/freeware/src/packages/BUILD/mysql-5.5.15/mysql-5.5.15/include   -o CMakeFiles/strings.dir/bchange.c.o   -c /opt/freeware/src/packages/BUILD/mysql-5.5.15/mysql-5.5.15/strings/bchange.c

"/opt/freeware/src/packages/BUILD/mysql-5.5.15/mysql-5.5.15/include/my_global.h", line 289.74: 1506-272 (E) Identifier not allowed in cast or sizeof declarations.

"/opt/freeware/src/packages/BUILD/mysql-5.5.15/mysql-5.5.15/include/my_global.h", line 289.76: 1506-046 (S) Syntax error.

"/usr/include/alloca.h", line 34.1: 1506-224 (I) Incorrect pragma ignored. 
make: 1254-004 The error code from the last command is 1. 
*************************************************************************************************************** 
          >>>>Souce list of compile command 
IBM XL C for AIX, Version 11.1.0.0 /opt/freeware/src/packages/BUILD/mysql-5.5.15/mysql-5.5.15/strings/bchange.c 08/16/11 16:41:58 (C)

>>>>> SOURCE SECTION <<<<< 

        1 | /* Copyright (c) 2000, 2001, 2006, 2007 MySQL AB 
        2 |    Use is subject to license terms. 
        3 | 
        4 |    This program is free software; you can redistribute it and/or modify 
        5 |    it under the terms of the GNU General Public License as published by 
        6 |    the Free Software Foundation; version 2 of the License. 
        7 | 
        8 |    This program is distributed in the hope that it will be useful, 
        9 |    but WITHOUT ANY WARRANTY; without even the implied warranty of 
       10 |    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
       11 |    GNU General Public License for more details. 
       12 | 
       13 |    You should have received a copy of the GNU General Public License 
       14 |    along with this program; if not, write to the Free Software 
       15 |    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */ 
       16 | 
       17 | /*  File   : bchange.c 
       18 |     Author : Michael widenius 
       19 |     Updated: 1987-03-20 
       20 |     Defines: bchange() 
       21 | 
       22 |     bchange(dst, old_length, src, new_length, tot_length) 
       23 |     replaces old_length characters at dst to new_length characters from 
       24 |     src in a buffer with tot_length bytes. 
       25 | */ 
       26 | 
       27 | #include <my_global.h> 
"/opt/freeware/src/packages/BUILD/mysql-5.5.15/mysql-5.5.15/include/my_global.h", line 289.74: 1506-272 (E) Identifier not allowed in cast or sizeof declarations.

"/opt/freeware/src/packages/BUILD/mysql-5.5.15/mysql-5.5.15/include/my_global.h", line 289.76: 1506-046 (S) Syntax error.

"/usr/include/alloca.h", line 34.1: 1506-224 (I) Incorrect pragma ignored. 
       28 | #include "m_string.h" 
       29 | 
       30 | void bchange(register uchar *dst, size_t old_length, register const uchar *src, 

****************************************************************************** 
"/opt/freeware/src/packages/BUILD/mysql-5.5.15/mysql-5.5.15/include/my_global.h", line 282.2: 1506-454 (I) ifdef condition evaluates to 1.

"/opt/freeware/src/packages/BUILD/mysql-5.5.15/mysql-5.5.15/include/my_global.h", line 289.74: 1506-272 (E) Identifier not allowed in cast or sizeof declarations.

"/opt/freeware/src/packages/BUILD/mysql-5.5.15/mysql-5.5.15/include/my_global.h", line 289.76: 1506-046 (S) Syntax error.

"/opt/freeware/src/packages/BUILD/mysql-5.5.15/mysql-5.5.15/include/my_global.h", line 289.78: 1506-481 (I) The end of the function may be reached without returning a value.

"/opt/freeware/src/packages/BUILD/mysql-5.5.15/mysql-5.5.15/include/my_global.h", line 289.78: 1506-414 (I) The parameter "A" is never referenced.

*************************************************************************************************** 
It appears the problem code is my_global.h- Snippet: 

/* Go around some bugs in different OS and compilers */ 
#ifdef _AIX                     /* By soren@t.dk */ 
#define _H_STRINGS 
#define _SYS_STREAM_H 
/* #define _AIX32_CURSES */     /* XXX: this breaks AIX 4.3.3 (others?). */ 
#define ulonglong2double(A) my_ulonglong2double(A) 
#define my_off_t2double(A)  my_ulonglong2double(A) 
C_MODE_START 
inline double my_ulonglong2double(unsigned long long A) { return (double A); } 
C_MODE_END 
#endif /* _AIX */ 
**************************** 
IBM says: 
Identifier not allowed in cast or sizeof declarations. 
Explanation: 
Only abstract declarators can appear in cast or sizeof expressions. 
User response: 
Remove the identifier from the cast or sizeof expression and replace it with an abstract declarator. 
******************************************** 
Any ideas on how to work around this problem would be very much appreciated. Thank you in advance.

How to repeat:
Repeat the cmake command using the xlC 11.1 compiler under AIX 6.1

Suggested fix:
Possible alteration of code for AIX
[3 Oct 2011 19:26] David Schroeder
mysql-5.5.16 failed with same problem as 5.5.15. I don't know much about C/C++ programming, but here is what I had to do to fix the problem (keeping in mind that mysql-5.5.10 successfully compiled using the same compiler.)

1). include/my_global.h I changed line 289 from inline double my_ulonglong2double(unsigned long long A) return(0);  to: double my_ulonglong2double(unsigned long long A); (This fixed the Indentifier not allowed in cast or sizeof declarations). However, I got a linkage error.

2). mysys/my_port.c  (This was missing--- I copied the one from mysql-5.5.10) I was getting a linkage error stating that my_ulonglong2double could not be resolved, so this fixed that problem.

3). This was probably not necessary, but I read that bzero was deprecated and should be replaced by memset. Thinking that the newest IBM compiler might have a problem with bzero, I wrote a perl script that replaced all 700+ bzero's with memset's. 

Now, I have a successful compile and the database appears to function normally. I hate to think that such an important database is moving away from AIX support.
[20 Feb 2012 19:32] Sveta Smirnova
Thank you for the report.

But AIX is not supported for version 5.5 according to http://www.mysql.com/support/supportedplatforms/database.html
[20 Jun 2016 22:10] P McCormick
I had this problem with MySQL 5.6.31, AIX 7.1, xlc 10.  I fixed it by changing line 281 of include/my_global.h from:

inline double my_ulonglong2double(unsigned long long A) { return (double A); }

to:
inline double my_ulonglong2double(unsigned long long A) { return ((double) A); }

that's it.

I just built the client, not the server.  Client seems to work fine.