This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

g++/gcc union bug


The following c++ source will cause an internal compiler error in 2.95.1:
(compiled with -O -DSHOW_GCC_BUG)

__Luke

// ipstring.cc
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>

// an MT-safe version of inet_ntoa , buf length >= 16
char *
IpString(char *buf, uint_t addr)
{
#ifdef SHOW_GCC_BUG
  union { uchar_t a[4]; uint_t ia; };
  ia = addr;
#else
  uchar_t *a = (uchar_t*)&addr;
#endif
  // of course endian dependent.
  sprintf(buf, "%u.%u.%u.%u", a[0], a[1], a[2], a[3]);
  return buf;
}

int main()
{
  char ips[16];
  srand(getpid());
  puts(IpString(ips, (rand()<<16)+rand()));
}

dexdev:~/test 1207> newg++ -v -save-temps -O -DSHOW_GCC_BUG ipstring.cc
Reading specs from
/home/dsimpson/bin/SunOS-5.6/gcc-2.95.1/lib/gcc-lib/sparc-sun-solaris2.6/2.
95.1/specs
gcc version 2.95.1 19990816 (release)

/home/dsimpson/bin/SunOS-5.6/gcc-2.95.1/lib/gcc-lib/sparc-sun-solaris2.6/2.
95.1/cpp -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cpl
usplus -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__u
nix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix -Asystem(unix) -Asyste
m(svr4) -D__EXCEPTIONS -D__OPTIMIZE__ -D__GCC_NEW_VARARGS__ -Acpu(sparc) -A
machine(sparc) -DSHOW_GCC_BUG ipstring.cc ipstring.ii
GNU CPP version 2.95.1 19990816 (release) (sparc)
#include "..." search starts here:
#include <...> search starts here:

/home/dsimpson/bin/SunOS-5.6/gcc-2.95.1/lib/gcc-lib/sparc-sun-solaris2.6/2.
95.1/../../../../include/g++-3
 /usr/local/include

/home/dsimpson/bin/SunOS-5.6/gcc-2.95.1/lib/gcc-lib/sparc-sun-solaris2.6/2.
95.1/../../../../sparc-sun-solaris2.6/include

/home/dsimpson/bin/SunOS-5.6/gcc-2.95.1/lib/gcc-lib/sparc-sun-solaris2.6/2.
95.1/include
 /usr/include
End of search list.
The following default directories have been omitted from the search path:
End of omitted list.

/home/dsimpson/bin/SunOS-5.6/gcc-2.95.1/lib/gcc-lib/sparc-sun-solaris2.6/2.
95.1/cc1plus ipstring.ii -quiet -dumpbase ipstring.cc -O -version -o
ipstring.s
GNU C++ version 2.95.1 19990816 (release) (sparc-sun-solaris2.6) compiled
by GNU C version 2.95.1 19990816 (release).
ipstring.cc: In function `char * IpString(char *, unsigned int)':
ipstring.cc:17: Internal compiler error in `change_address', at
emit-rtl.c:1604
Please submit a full bug report.
See <URL:http://www.gnu.org/software/gcc/faq.html#bugreport> for
instructions.

ipstring.ii.bz2


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]