[gambit-list] Re: cadar: compiler bug?

Marc Feeley feeley at iro.umontreal.ca
Fri Jul 15 17:14:34 EDT 2005


On 15-Jul-05, at 8:18 PM, Sven.Hartrumpf at fernuni-hagen.de wrote:

> Hi all.
>
> I managed to isolate a long standing problem for my programs:
>
>
>> cat a.scm
>>
> (write (cadar (read)))
>
>> gsc a.c
>> gcc344 a.c a_.c -lgambc -lm -lutil -ldl
>> echo "((11 12 13) (21 22 23) (31 32 33))" | a.out
>>
> 21
>
> The result of the interpreter looks much better:
> 12
>
> Current beta of Gambit (and before), Linux i386, gcc 3.4.4.
>
> Hope this helps.
>
> Greetings
> Sven
>

Oh my... what a stupid mistake!

To fix it you will have to make the following change to gsc/_t- 
c-2.scm and recompile the compiler (with a "make").  Change the  
definition

       (define (gen-c...r pattern var)
         (if (< pattern 4)
           (gen-tst-pair
            pattern
            var
            (new-cst source env
              #f)
            check-run-time-binding)
           (let ((vars (gen-temp-vars source '(#f))))
             (new-call source env
               (gen-prc source env
                 vars
                 (gen-c...r (quotient pattern 2) (car vars)))
               (list
                (gen-tst-pair
                 pattern
                 var
                 (new-cst source env
                   #f)
                 #f))))))

to

       (define (gen-c...r pattern var)
         (if (< pattern 4)
           (gen-tst-pair
            pattern
            var
            (new-cst source env
              #f)
            check-run-time-binding)
           (let ((vars (gen-temp-vars source '(#f))))
             (new-call source env
               (gen-prc source env
                 vars
                 (gen-tst-pair
                  pattern
                  (car vars)
                  (new-cst source env
                    #f)
                  #f))
               (list (gen-c...r (quotient pattern 2) var))))))

Marc




More information about the Gambit-list mailing list