Opened 5 years ago
Closed 5 years ago
#1630 closed defect (fixed)
Optimizer sometimes incorrectly drops procedure arguments
Reported by: | sjamaan | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 5.2 |
Component: | compiler | Version: | 5.1.0 |
Keywords: | Cc: | ||
Estimated difficulty: | hard |
Description (last modified by )
Found by megane while looking into a patch of mine to improve variable replacements:
(define (foo bindings) (define (append-map proc lst1) (if lst1 (proc 1) (proc 1 2))) (append-map (lambda (b a) (begin)) bindings))
Compile this with -O3 and it will error out with this message:
Error: Arguments to inlined call of `a150' do not match parameter-list (b a)
After fixing this, we can remove the (not captured)
test in the 'replaceable
code.
Change History (9)
comment:1 Changed 5 years ago by
Description: | modified (diff) |
---|
comment:2 Changed 5 years ago by
Summary: | Optimizer may incorrectly drop procedure arguments → Optimizer sometimes incorrectly drops procedure arguments |
---|
comment:3 Changed 5 years ago by
comment:4 Changed 5 years ago by
I don't see the problem here. Tha example code is clearly incorrect.
comment:5 Changed 5 years ago by
Resolution: | → worksforme |
---|---|
Status: | new → closed |
comment:6 Changed 5 years ago by
Resolution: | worksforme |
---|---|
Status: | closed → reopened |
This fails too, but shouldn't. The true branch is never called.
(define (foo x y) (define (append-map proc lst1 . lsts) (if (null? lsts) (proc 1) (proc 1 2))) (append-map (lambda (a b) (print a b)) x y))
comment:7 Changed 5 years ago by
This code seems valid to me but also triggers the error when compiled with -O2:
(define (foo x y) (define (append-map proc lst1 . lsts) (if (null? lsts) (proc 1) (proc 1 2))) (append-map (lambda (a b) (print a b)) x y) (append-map (lambda (a) (print a)) x))
comment:8 Changed 5 years ago by
Estimated difficulty: | medium → hard |
---|
Here is another test, submitted by megane. This triggers a compiler error, with the standard CHICKEN:
(define (foo x y) (define (append-map proc . lsts) (if (null? lsts) (proc 1) (apply proc lsts))) (append-map (lambda (a) (print a))) (append-map (lambda (a b) (print a b)) x y)) (foo 3 4)
comment:9 Changed 5 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Fixed by cf5d2aed000cfd292708d41b3774321bfec5eb67
Simpler still: