startup bug in gcc-2.95.2 ?

Alan Stange stange@rentec.com
Mon Mar 27 08:35:00 GMT 2000


Hello all,

I have the following on a SuSE Linux 6.3 system.  The small code, when
compiled with optimization, works fine; without the optimizer, the code
fails.  This code does run fine on many other platforms and with other
compilers, so there appears to be something happening on the i686
platform.

Also, note that changing the line

  valarray<double> w(y*exp(y));
to use a temporary  (d = exp(y); w(y*d)) then the code runs OK.


monster$ /usr/local/gnu/bin/g++ --version
pgcc-2.95.2
monster$ /usr/local/gnu/bin/g++ a.C
monster$ cat a.C

#include <iostream>
#include <fstream>
#include <algorithm>
#include <valarray>
#include <map>
#include <string>

using namespace std;

ostream&
operator<<(ostream& os, const valarray<double>& data)
{
  for(unsigned i = 0; i < data.size(); i++ ){
    os << data[i] << " ";
  }
  return os;
}

int
main(int argc, char** argv)
{
  map<string, double> x;

  valarray<double> y(10000);
  for(unsigned i = 0; i < y.size(); i++ ){
    y[i] = 4.5;
  }
  valarray<double> w(y*exp(y));
  cout << w << endl;

}


monster$ a.out
Aborted

Here is the stack trace from gdb:

Program received signal SIGABRT, Aborted.
0x2ab07c11 in __kill () from /lib/libc.so.6
(gdb) where
#0  0x2ab07c11 in __kill () from /lib/libc.so.6
#1  0x2ab0781f in raise (sig=6) at ../sysdeps/posix/raise.c:27
#2  0x2ab09053 in abort () at ../sysdeps/generic/abort.c:88
#3  0x804f4bb in __default_terminate ()
#4  0x804f4e0 in __terminate ()
#5  0x804feab in throw_helper (eh=0x805b35c, pc=0x2ab01312,
    my_udata=0x7ffff6b0, offset_p=0x7ffff6ac)
#6  0x805008b in __throw ()
#7  0x804a855 in main ()
#8  0x2ab01313 in __libc_start_main (main=0x804a740 <main>, argc=1,
    argv=0x7ffff7e4, init=0x804a10c <_init>, fini=0x80555c8 <_fini>,
    rtld_fini=0x2aab5c70 <_dl_fini>, stack_end=0x7ffff7dc)
    at ../sysdeps/generic/libc-start.c:90


--
Alan L. Stange     Renaissance Technologies Corp.    stange@rentec.com





More information about the Gcc-bugs mailing list