ewx: (geek)
[personal profile] ewx

Does anyone have access to a more recent version of IBM's AIX C compiler than 5.0.2.0?

...and if so could they run this test program as shown? It does matter that it's the native compiler, not gcc, and that 32-bit mode is used. I'd like to know whether IBM have fixed it before reporting it...

-bash-2.05b$ cat t.c
#include <assert.h>
#include <string.h>

int main(int argc, char **argv) {
  assert((strlen)(argv[1]) < 0xffffffffu);
  assert(strlen(argv[1]) < 0xffffffffu);
  return 0;
}
-bash-2.05b$ /usr/vac/bin/xlc -g -o t t.c && ./t spong
Assertion failed: strlen(argv[1]) < 0xffffffffu, file  t.c, line 9
IOT/Abort trap (core dumped)
-bash-2.05b$ gdb t
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "powerpc-ibm-aix5.1.0.0"...
(gdb) disassemble main
Dump of assembler code for function main:
0x10000350 <main+0>:    mflr    r0
0x10000354 <main+4>:    stw     r31,-4(r1)
0x10000358 <main+8>:    stw     r0,8(r1)
0x1000035c <main+12>:   stwu    r1,-80(r1)
0x10000360 <main+16>:   lwz     r31,68(r2)
0x10000364 <main+20>:   stw     r3,104(r1)
0x10000368 <main+24>:   stw     r4,108(r1)
0x1000036c <main+28>:   lwz     r3,108(r1)
0x10000370 <main+32>:   lwz     r3,4(r3)
0x10000374 <main+36>:   bl      0x10000468 <strlen>
0x10000378 <main+40>:   lwz     r2,20(r1)
0x1000037c <main+44>:   li      r4,0
0x10000380 <main+48>:   addi    r4,r4,-1
0x10000384 <main+52>:   cmplw   r3,r4
0x10000388 <main+56>:   bge-    0x10000390 <main+64>
0x1000038c <main+60>:   b       0x100003a4 <main+84>
0x10000390 <main+64>:   ori     r3,r31,0
0x10000394 <main+68>:   addi    r4,r31,32
0x10000398 <main+72>:   li      r5,8
0x1000039c <main+76>:   bl      0x10000490 <__assert>
0x100003a0 <main+80>:   lwz     r2,20(r1)
0x100003a4 <main+84>:   lwz     r3,108(r1)
0x100003a8 <main+88>:   lwz     r3,4(r3)
0x100003ac <main+92>:   bl      0x10000468 <strlen>
0x100003b0 <main+96>:   lwz     r2,20(r1)
0x100003b4 <main+100>:  li      r4,0
0x100003b8 <main+104>:  addi    r4,r4,-1
0x100003bc <main+108>:  cmpw    r3,r4
0x100003c0 <main+112>:  bge-    0x100003c8 <main+120>
0x100003c4 <main+116>:  b       0x100003dc <main+140>
0x100003c8 <main+120>:  addi    r3,r31,36
0x100003cc <main+124>:  addi    r4,r31,32
0x100003d0 <main+128>:  li      r5,9
0x100003d4 <main+132>:  bl      0x10000490 <__assert>
0x100003d8 <main+136>:  lwz     r2,20(r1)
0x100003dc <main+140>:  li      r3,0
0x100003e0 <main+144>:  b       0x100003e4 <main+148>
0x100003e4 <main+148>:  lwz     r0,88(r1)
0x100003e8 <main+152>:  mtlr    r0
0x100003ec <main+156>:  addi    r1,r1,80
0x100003f0 <main+160>:  lwz     r31,-4(r1)
0x100003f4 <main+164>:  blr
0x100003f8 <main+168>:  .long 0x0
0x100003fc <main+172>:  .long 0x2041
0x10000400 <main+176>:  lwz     r0,513(r1)
0x10000404 <main+180>:  .long 0x0
0x10000408 <main+184>:  .long 0xa8
0x1000040c <main+188>:  .long 0x46d61
0x10000410 <main+192>:  xori    r14,r11,0
End of assembler dump.
-bash-2.05b$ grep -r __strlen /usr/include/
/usr/include/string.h:#       define strlen(__s1) __strlen(__s1)
-bash-2.05b$ lslpp -l|grep -E vac\\.C\|xlC
  vac.C                      5.0.2.0  COMMITTED  C for AIX Compiler
  vac.C.readme.ibm           5.0.2.0  COMMITTED  C for AIX iFOR/LS Information
  xlC.aix50.rte              5.0.2.2  COMMITTED  C Set ++ Runtime for AIX 5.0
  xlC.cpp                    5.0.2.0  COMMITTED  C for AIX Preprocessor
  xlC.msg.en_US.cpp          5.0.2.0  COMMITTED  C for AIX Preprocessor
  xlC.msg.en_US.rte          5.0.2.0  COMMITTED  C Set ++ Runtime
  xlC.rte                    5.0.2.1  COMMITTED  C Set ++ Runtime
  vac.C                      5.0.2.0  COMMITTED  C for AIX Compiler

(If you don't have a PPC disassembler you know how to drive to hand, xlc -S t.c will give you the assembly output in t.s.)

Update: AIX 5.3's compiler does not appear to have this bug.

-bash-3.00$ uname -a
AIX devaix53 3 5 00C5B22D4C00 powerpc unknown AIX
-bash-3.00$ cat t.c
#include <assert.h>
#include <string.h>

int main(int argc, char **argv) {
  assert((strlen)(argv[1]) < 0xffffffffu);
  assert(strlen(argv[1]) < 0xffffffffu);
  return 0;
}
-bash-3.00$ /usr/vac/bin/xlc -g -o t t.c && ./t spong
-bash-3.00$ echo $?
0
-bash-3.00$ lslpp -l|grep -E vac\\.C\|xlC
  vac.C                      9.0.0.0  COMMITTED  IBM XL C Compiler
  xlC.adt.include            9.0.0.0  COMMITTED  C Set ++ Application
  xlC.aix50.rte              9.0.0.1  COMMITTED  XL C/C++ Runtime for AIX 5.2
  xlC.cpp                    9.0.0.0  COMMITTED  C for AIX Preprocessor
  xlC.msg.en_US.cpp          9.0.0.0  COMMITTED  C for AIX Preprocessor
  xlC.msg.en_US.rte          9.0.0.1  COMMITTED  XL C/C++ Runtime
  xlC.rte                    9.0.0.1  COMMITTED  XL C/C++ Runtime
  vac.C                      9.0.0.0  COMMITTED  IBM XL C Compiler

November 2025

S M T W T F S
      1
2345678
91011121314 15
1617 181920 2122
23242526272829
30      

Most Popular Tags

Expand Cut Tags

No cut tags