Opened 3 years ago

Last modified 13 months ago

#1258 new defect

At higher optimization levels, some scrutiny warnings disappear

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


(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 (4)

comment:1 Changed 2 years ago by sjamaan

  • Estimated difficulty set to hard

comment:2 Changed 22 months 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 22 months ago by evhan

  • Priority changed from major to minor
  • Version changed from 4.10.x to 5.0

comment:4 Changed 13 months ago by felix

  • Milestone changed from 5.0 to 5.1
Note: See TracTickets for help on using tickets.