Opened 4 years ago

Last modified 5 months ago

#1258 new defect

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

comment:1 Changed 3 years ago by sjamaan

Estimated difficulty: hard

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

Priority: majorminor
Version: 4.10.x5.0

comment:4 Changed 21 months ago by felix winkelmann

Milestone: 5.05.1

comment:5 Changed 5 months ago by sjamaan

Milestone: 5.15.2

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

Note: See TracTickets for help on using tickets.