Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

IA64 optimization problem

akr
Beginner
270 Views

Hi.

I found that following program dumps core if it is optimized with Intel C++ Compiler 9.0 on IA64. It dumps core only if optimization is enabled.

Is there any workaround for this problem?

td177.testdrive.hp.com> icc --version
icc (ICC) 9.0  20051020
Copyright (C) 1985-2005 Intel Corporation.  All rights reserved.

I used icc on HP TestDrive.

td177.testdrive.hp.com> cat tst.c 
#include 
#include 

int flag;
ucontext_t cont;

int v1=1, v2=2;
int
  x00= 0, x01= 1, x02= 2, x03= 3, x04= 4, x05= 5, x06= 6, x07= 7, x08= 8, x09= 9,
  x10=10, x11=11, x12=12, x13=13, x14=14, x15=15, x16=16, x17=17, x18=18, x19=19,
  x20=20, x21=21, x22=22, x23=23, x24=24, x25=25, x26=26, x27=27, x28=28, x29=29;

int main(int argc, char **argv)
{
  int ret;

  flag = 0;

  printf("%d %d
", v1, v2);
  getcontext(&cont);
  printf("%d %d
", v1, v2);
  printf(
    "%d %d %d %d %d %d %d %d %d %d "
    "%d %d %d %d %d %d %d %d %d %d "
    "%d %d %d %d %d %d %d %d %d %d
",
    x00, x01, x02, x03, x04, x05, x06, x07, x08, x09,
    x10, x11, x12, x13, x14, x15, x16, x17, x18, x19,
    x20, x21, x22, x23, x24, x25, x26, x27, x28, x29);

  ret = flag;
  if (ret == 0) {
    flag = 1;
    setcontext(&cont);
  }
  return ret;
}
td177.testdrive.hp.com> icc -g -O0 tst.c
td177.testdrive.hp.com> ./a.out
1 2
1 2
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
1 2
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

It works well if -O0.

td177.testdrive.hp.com> icc -g -O2 tst.c
td177.testdrive.hp.com> ./a.out
1 2
1 2
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
Segmentation fault (core dumped)

It dumps core if -O2.

td177.testdrive.hp.com> gdb a.out core.6476 
GNU gdb Red Hat Linux (6.3.0.0-1.63rh)
Copyright 2004 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 "ia64-redhat-linux-gnu"...Using host libthread_db library "/lib/tls/libthread_db.so.1".

Reading symbols from shared object read from target memory...done.
Loaded system supplied DSO at 0xa000000000000000
Core was generated by `./a.out'.
Program terminated with signal 11, Segmentation fault.

warning: svr4_current_sos: Can't read pathname for load map: Input/output error

Reading symbols from /opt/intel/cc/9.0/lib/libimf.so.6...done.
Loaded symbols for /opt/intel/cc/9.0/lib/libimf.so.6
Reading symbols from /lib/tls/libm.so.6.1...done.
Loaded symbols for /lib/tls/libm.so.6.1
Reading symbols from /opt/intel/cc/9.0/lib/libipr.so.6...done.
Loaded symbols for /opt/intel/cc/9.0/lib/libipr.so.6
Reading symbols from /lib/libgcc_s.so.1...done.
Loaded symbols for /lib/libgcc_s.so.1
Reading symbols from /lib/tls/libc.so.6.1...done.
Loaded symbols for /lib/tls/libc.so.6.1
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/ld-linux-ia64.so.2...done.
Loaded symbols for /lib/ld-linux-ia64.so.2
#0  main (argc=23, argv=0x18) at tst.c:21
21        printf("%d %d
", v1, v2);
(gdb) bt
#0  main (argc=23, argv=0x18) at tst.c:21
(gdb) 

Note that this problem is very similar to a bug in gcc 4.0.2 or prior. GCC Bug 21957

0 Kudos
0 Replies
Reply