bugKawa - Bugs: bug #36334, Premature constant folding on...


bug #36334: Premature constant folding on statically typed variables

Submitted by:  Charles Turner <charlest>
Submitted on:  Sun 29 Apr 2012 11:13:41 AM UTC  
Category:  Code generation Severity:  3 - Normal
Item Group:  Unexpected result Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Sun 29 Apr 2012 11:13:41 AM UTC, original submission:

Consider this interaction:

(define (test)
(let ((x :: integer 10.5))
(* x x)))
/dev/stdin:2:23: warning - type DFloNum is incompatible with required
type integer
/dev/stdin:3:5: warning - cannot convert literal (of type
gnu.math.DFloNum) to Type integer

So far, as expected. But when you type (test), you get:

Value '110.25' has wrong type (DFloNum) (expected: integer)

(* 10.5 10.5) is being folded too soon, Kawa should fail when it sees that the cast can not be satisfied.

Some explanation from Per on the mailing lists

"This looks like a bug in constant folding.
We're multiplying 10.5 and 10.5 - and eliminating the cast/conversion
of 10.5 to integer. In this case we know the cast always
fails, so we shouldn't do the constant-folding. But even if the
cast succeeds, we need to used the converted value.

This issue seems related to the unreachable-code issue. I.e. the
type x really should be "unreachable" or Type.neverReturnsType.
I am looking at improvements in the area of unreachable code"

Charles Turner <charlest>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by charlest (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    No changes have been made to this item

    Back to the top

    Powered by Savane 3.3