gcc 2.91.50: incorrect behaviour when rx-1.5 is compiled with -O

Joseph Heled pepe@iconz.co.nz
Thu Jul 16 14:25:00 GMT 1998


I am sorry that I don't have the time to pinpoint this bug exactly, but I
believe it is serious enough to report, since many people might be effected if
egcs is released with it.
I think there is no need that I send the sources of rx-1.5. You probably have
them or can easily get them. 

I will be happy to assist further if you can't reproduce the bug.

thanks!

The bug manifests itself when I compile rx-1.5 with -O. I did go in with gdb as
far as I could into rx-1.5 code, but finding out exactly what went wrong is
beyond me.

Here is the small C program

------------------------------------------------------
#include <assert.h>
#include <stddef.h>
#include <stdio.h>

#include <rxposix.h>

int
main()
{
  const char* p = "[[:blank:]]*\\([^[:blank:]]*\\)[[:blank:]]*\\(.*\\)";
  const char* l  = "TOCbody";
  int s;
  
  regmatch_t m[11];
  
  regex_t pat;
  regex_t* pattern = &pat;
    
  s = regcomp(pattern, p, 0);

  assert( s == REG_NOERROR );
  

  s = regexec(pattern, l, 11, m, 0);

  assert( s == REG_NOERROR );

  {
    unsigned int k;
    for(k = 0; k < 3; ++k) {
      printf("%d: %d %d\n", k, m[k].rm_so, m[k].rm_eo);
    }
  }
  return 0;
}
-------------------------------------------

When linked with the non opt version it produces the correct output,

0: 0 7
1: 0 7
2: 7 7

When linked with the version compiled with -O, it produces

0: 0 7
1: 0 0
2: 0 0




uname -a: SunOS zeal 5.5 Generic sun4u sparc SUNW,Ultra-1

compilation line used 

home/joseph/egcs/bin/gcc -Vegcs-2.91.50 -v -g -Id4cab/include
-Ld4cab/packages/rx-1.5/rx b1.c -o b1 -lrx
Reading specs from
/home/joseph/egcs/lib/gcc-lib/sparc-sun-solaris2.5/egcs-2.91.50/specs
gcc version egcs-2.91.50 19980714 (gcc2 ss-980609 experimental)
 /home/joseph/egcs/lib/gcc-lib/sparc-sun-solaris2.5/egcs-2.91.50/cpp -lang-c -v
-Id4cab/include -undef -D__GNUC__=2 -D__GNUC_MINOR__=91 -Dsparc -Dsun -Dunix
-D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4
-D__sparc -D__sun -D__unix -Asystem(unix) -Asystem(svr4) -g
-D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine(sparc) b1.c /var/tmp/ccMldUGV.i
GNU CPP version egcs-2.91.50 19980714 (gcc2 ss-980609 experimental) (sparc)
#include "..." search starts here:
#include <...> search starts here:
 d4cab/include
 /usr/local/include
 /home/joseph/egcs/sparc-sun-solaris2.5/include
 /home/joseph/egcs/lib/gcc-lib/sparc-sun-solaris2.5/egcs-2.91.50/include
 /usr/include
End of search list.
 /home/joseph/egcs/lib/gcc-lib/sparc-sun-solaris2.5/egcs-2.91.50/cc1
/var/tmp/ccMldUGV.i -quiet -dumpbase b1.c -g -version -o /var/tmp/cchhIXyX.s
GNU C version egcs-2.91.50 19980714 (gcc2 ss-980609 experimental)
(sparc-sun-solaris2.5) compiled by GNU C version egcs-2.91.47 19980707 (gcc2
ss-980609 experimental).
 /usr/ccs/bin/as -V -Qy -s -o /var/tmp/cc6oGJGf.o /var/tmp/cchhIXyX.s
/usr/ccs/bin/as: SC4.0 dev 15 Feb 1995
 /home/joseph/egcs/lib/gcc-lib/sparc-sun-solaris2.5/egcs-2.91.50/collect2 -V -Y
P,/usr/ccs/lib:/usr/lib -Qy -o b1
/home/joseph/egcs/lib/gcc-lib/sparc-sun-solaris2.5/egcs-2.91.50/crt1.o
/home/joseph/egcs/lib/gcc-lib/sparc-sun-solaris2.5/egcs-2.91.50/crti.o
/usr/ccs/lib/values-Xa.o
/home/joseph/egcs/lib/gcc-lib/sparc-sun-solaris2.5/egcs-2.91.50/crtbegin.o
-Ld4cab/packages/rx-1.5/rx
-L/home/joseph/egcs/lib/gcc-lib/sparc-sun-solaris2.5/egcs-2.91.50
-L/home/joseph/egcs/sparc-sun-solaris2.5/lib -L/usr/ccs/bin -L/usr/ccs/lib
-L/home/joseph/egcs/lib /var/tmp/cc6oGJGf.o -lrx -lgcc -lc -lgcc
/home/joseph/egcs/lib/gcc-lib/sparc-sun-solaris2.5/egcs-2.91.50/crtend.o
/home/joseph/egcs/lib/gcc-lib/sparc-sun-solaris2.5/egcs-2.91.50/crtn.o
ld: Software Generation Utilities (SGU) SunOS/ELF (LK-2.0 (S/I) - versioning)

Compilation finished at Fri Jul 17 08:29:42



More information about the Gcc-bugs mailing list