This is the mail archive of the
guile@sources.redhat.com
mailing list for the Guile project.
Re: Subtle bug with GCC optimization?
- To: Marius Vollmer <mvo at zagadka dot ping dot de>
- Subject: Re: Subtle bug with GCC optimization?
- From: Mikael Djurfeldt <mdj at mdj dot nada dot kth dot se>
- Date: 14 Aug 2000 00:38:29 +0200
- Cc: guile at sourceware dot cygnus dot com
- Cc: djurfeldt at nada dot kth dot se
- References: <873dk8al8d.fsf@zagadka.ping.de>
- Reply-To: djurfeldt at nada dot kth dot se
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.