Summary

+inf.0 inserted literally into C code in some situations with -O3 and above

Metadata

Attachments

Description

For example, the following code doesn't compile due to this:

 (import chicken.flonum)
 
 (define x 5.0)
 (cond [(fp= x +inf.0)
        (fpabs x)]
       [else (print "Nothing")])

With the first few errors being:

 test.c:110:74: error: ‘inf’ undeclared (first use in this function); did you mean ‘ynf’?
   110 | if(C_truep(C_ub_i_flonum_equalp(C_flonum_magnitude(*((C_word*)lf[0]+1)),+inf.0))){
       |                                                                          ^~~
 /usr/include/chicken/chicken.h:1035:38: note: in definition of macro ‘C_truep’
  1035 | #define C_truep(x)                 ((x) != C_SCHEME_FALSE)
       |                                      ^

Weirdly enough, if I replace fpabs with print, the compilation goes fine.

Changes and comments

[2019-06-27 04:23:45 UTC] dieggsy attached gcc-errors.txt (description=gcc errors)

[2019-06-27 04:32:46 UTC] dieggsy wrote:

If I bind +inf.0 to a variable beforehand -- (define y +inf.0) -- and bind that instead, it seems to work as expected.

[2019-06-27 08:37:57 UTC] sjamaan set difficulty to medium

[2019-06-27 08:37:57 UTC] sjamaan changed milestone from someday to 5.2

[2019-06-27 08:37:57 UTC] sjamaan wrote:

Evan thinks this is due to flonum unboxing handling literals wrong

[2019-06-30 11:18:28 UTC] sjamaan changed status from new to closed

[2019-06-30 11:18:28 UTC] sjamaan set resolution to fixed

[2019-06-30 11:18:28 UTC] sjamaan wrote:

Fixed with 0ef1522