Opened 4 years ago

Closed 2 months ago

#1258 closed defect (fixed)

At higher optimization levels, some scrutiny warnings disappear

Reported by: sjamaan Owned by:
Priority: minor Milestone: 5.2
Component: scrutinizer Version: 5.0.0
Keywords: Cc:
Estimated difficulty: hard

Description

(use data-structures)
(print (sort '(x y z) (lambda (a b) (> a b))))

When compiled with -O2 or lower, this gives the warning:

Warning: at toplevel:
  (/tmp/test.scm:5) in procedure call to `sort',
  expected argument #2 of type `(procedure (symbol symbol) *)'
  but was given an argument of type `(procedure (number number) boolean)'

When compiled with -O3 or higher, no output is given.

The warning is always shown in master, as far as I can tell.

Change History (6)

comment:1 Changed 3 years ago by sjamaan

Estimated difficulty: hard

comment:2 Changed 3 years ago by sjamaan

As pointed out by TheLemonMan?, this is caused by the rewrite for > that was introduced by c493d5100. The diff is:

-   ((number number) (##core#inline "C_i_greaterp" #(1) #(2))))
+   ((* *) (##core#inline "C_i_greaterp" #(1) #(2))))

Apparently the rewrite happens so early that the scrutinizer has no opportunity to detect that the argument to sort is wrong.

The rewrite itself seems correct to me, because it is more efficient than rewriting only numbers, if the compiler doesn't know the types (C_i_greaterp will raise a runtime error if it is passed non-numbers).

comment:3 Changed 3 years ago by evhan

Priority: majorminor
Version: 4.10.x5.0

comment:4 Changed 2 years ago by felix winkelmann

Milestone: 5.05.1

comment:5 Changed 7 months ago by sjamaan

Milestone: 5.15.2

Getting ready for 5.1, moving tickets which won't make it in to 5.2.

comment:6 Changed 2 months ago by felix winkelmann

Resolution: fixed
Status: newclosed

Commit bc72c05fa61581fc1fa86e90000a002847c3f28b removed the generalization in types.db.

Note: See TracTickets for help on using tickets.