This is the mail archive of the
guile@sources.redhat.com
mailing list for the Guile project.
Re: Subtle bug with GCC optimization?
- To: djurfeldt at nada dot kth dot se
- Subject: Re: Subtle bug with GCC optimization?
- From: Gary Houston <ghouston at arglist dot com>
- Date: 14 Aug 2000 07:14:32 -0000
- CC: mvo at zagadka dot ping dot de, guile at sourceware dot cygnus dot com, djurfeldt at nada dot kth dot se
- References: <873dk8al8d.fsf@zagadka.ping.de> <xy74s4oaisa.fsf@mdj.nada.kth.se>
> From: Mikael Djurfeldt <mdj@mdj.nada.kth.se>
> Date: 14 Aug 2000 00:38:29 +0200
> Marius Vollmer <mvo@zagadka.ping.de> writes:
>
> > after changing something in scm_ithrow, Guile crashed for me when
> > there was no matching tag on the wind list. It crashed only when
> > compiled with -O2 on i386. I traced it to the following code:
> >
> > for (winds = dynwinds; SCM_NIMP (winds); winds = SCM_CDR (winds))
> > {
> > if (! SCM_CONSP (winds))
> > abort ();
> >
> > dynpair = SCM_CAR (winds);
> > ...
> > }
> >
> > which is compiled to this code fragment (see below for complete
> > listings):
> >
> > movl %ecx,%ebx
> > andl $6,%ebx ;; SCM_NIMP
> > movl (%ecx),%edx ;; SCM_CAR -> crash!
> > jne .L19
> > testb $1,%dl ;; SCM_CONSP
> > je .L22
> > call abort
> > .p2align 4,,7
> >
> > As you can see, the code checks whether winds is NIMP and takes it CAR
> > regardless (probably because it is needed to check for CONSP).
> >
> > Is GCC allowed to do that?
>
> Wow! 8-o
>
> No, I don't think so. First I thought that if we have the SCM type
> defined as a void *, GCC might have the right to assume that it's
> valid.
>
> But this is not the default.
>
> My guess it that it is a GCC bug.
It looks like the same GCC bug we ran into a few months ago: try adding
-fno-gcse.
Search for gcse at:
http://sources.redhat.com/ml/bug-guile/
or search for ghouston at:
http://gcc.gnu.org/ml/gcc-bugs/