From cmucl-devel at common-lisp.net Fri Mar 5 19:17:30 2010 From: cmucl-devel at common-lisp.net (cmucl) Date: Fri, 05 Mar 2010 19:17:30 -0000 Subject: [cmucl-ticket] [cmucl] #38: Inlining loses declarations Message-ID: <054.81a4393a29b3154b196650c9e51b2540@common-lisp.net> #38: Inlining loses declarations --------------------+------------------------------------------------------- Reporter: heller | Owner: somebody Type: defect | Status: new Priority: minor | Milestone: Component: Core | Version: 20a Keywords: | --------------------+------------------------------------------------------- I'd like to write a function fx+ which is like + but only accepts fixnums as arguments and never conses, i.e. it's considered an error if the sum is not a fixnum. Arguments and return value should be checked. Essentially this {{{ (declaim (inline fx+)) (defun fx+ (x y) (declare (fixnum x y) (values fixnum)) (+ x y)) }}} is what I want. If called as (fx+ 1 most-positive-fixnum) the error is detected as it should be. But after inlining {{{ (defun foo (x y) (fx+ x y)) }}} and using it like (foo 1 most-positive-fixnum) it returns -536870912. -- Ticket URL: cmucl cmucl From cmucl-devel at common-lisp.net Mon Mar 22 15:38:59 2010 From: cmucl-devel at common-lisp.net (cmucl) Date: Mon, 22 Mar 2010 15:38:59 -0000 Subject: [cmucl-ticket] [cmucl] #38: Inlining loses declarations In-Reply-To: <054.81a4393a29b3154b196650c9e51b2540@common-lisp.net> References: <054.81a4393a29b3154b196650c9e51b2540@common-lisp.net> Message-ID: <063.47095684c3ca3aced69559270def66b6@common-lisp.net> #38: Inlining loses declarations ---------------------+------------------------------------------------------ Reporter: heller | Owner: somebody Type: defect | Status: new Priority: minor | Milestone: Component: Core | Version: 20a Resolution: | Keywords: ---------------------+------------------------------------------------------ Comment(by rtoy): I'm not 100% sure, but it looks like the compiler believes the derived function type and inlines the function without the type check for the result type. This bug does not exist in 18b, but 18b doesn't inline the function; it tail calls fx+. 18c and later actually inline the function and produces the unwanted result. I agree that it would be nicer if the inlined function behaved like the not-inlined version. It seems the only way to get what you want is put an explicit check-type call. -- Ticket URL: cmucl cmucl