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

 
 

bug #36334: Premature constant folding on statically typed variables

Submitter:  Charles Turner <charlest>
Submitted:  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
* Mandatory Fields

Add a New Comment Rich Markup
   

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:
   
   
Comment:
   

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)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-cf05.
    Corresponding source code