Opened 22 months ago

Last modified 9 months ago

#1258 new defect

At higher optimization levels, some scrutiny warnings disappear

Reported by: sjamaan Owned by:
Priority: minor Milestone: 5.0
Component: scrutinizer Version: 5.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 (3)

comment:1 Changed 15 months ago by sjamaan

  • Estimated difficulty set to hard

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

  • Priority changed from major to minor
  • Version changed from 4.10.x to 5.0
Note: See TracTickets for help on using tickets.