Summary
Negative zero literals are miscompiled
Metadata
- Id: 25b1a579ebc754feb9eff2d1b0d78c618abd90e0
- Trac id: 1627
- Type: defect
- Reporter: johnwcowan
- Owner:
- Cc:
- Status: closed
- Component: unknown
- Estimated difficulty: easy
- Resolution: worksforme
- Priority: minor
- Milestone: 6.0.0
- Version: 5.1.0
- Changetime: 2023-11-08 13:12:21 UTC
- Created: 2019-06-28 04:49:03 UTC
- Keywords: float, negative zero
Description
All versions of the Chicken compiler and interpreter (since 5.0 at least) treat the Scheme literal value `-0.0` incorrectly. This inexact value is distinct from `0.0` in certain ways: for example, `(/ 1.0 0.0) => +inf.0`, but `(/ 1.0 -0.0) => -inf.0`.
Unfortunately, C treats the expression `-0.0` as a synonym for `0.0`, because in C a prefixed minus sign is always the negation operator and not part of a literal. So generating `-0.0` as the C representation of Scheme `-0.0` is incorrect. Instead, the C expression `(1.0 / (-INFINITY))`, where `INFINITY` is a constant from `math.h`, should be generated instead.
Changes and comments
[2023-11-06 23:34:25 UTC] felix changed milestone from someday to 6.0.0
[2023-11-07 18:18:10 UTC] felix wrote:
Is this still relevant? I can't seem to reproduce the problem.