Opened 12 years ago

Closed 12 years ago

Last modified 44 years ago

#85 closed bug (Duplicate)

ghc -O generates faulty c code

Reported by: nobody Owned by: nobody
Priority: normal Milestone:
Component: Compiler Version: 5.04
Keywords: Cc:
Operating System: Architecture:
Type of failure: Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

I have the following file:

Bug.hs
--------------------------
module Bug where

foo :: Double -> Double
foo x = x - (-1.0) 
--------------------------

> ghc -c -O Bug.hs
/tmp/ghc25320.hc: In function `s3Ny_ret':
/tmp/ghc25320.hc:14: invalid lvalue in decrement
/tmp/ghc25320.hc:14: parse error before `1.0'

Cause
-----

The problem is the following generated c snippet

_s3Nx_=PK_DBL((W_*)(R1.p+1))--1.0;

The two consecutive minuses should be separated by a
space.

Ulf Norell
ulfn@cs.chalmers.se

Change History (2)

comment:1 Changed 12 years ago by spanne

Logged In: YES 
user_id=50298

I've tested it with 5.02.3, 5.04.1 and the CVS HEAD and it
works fine in all cases (i.e.the literal is correctly
wrapped into parentheses). Which version are you using exactly?

comment:2 Changed 12 years ago by simonmar

  • Status changed from assigned to closed
Logged In: YES 
user_id=48280

This was fixed in 5.04.1 (also reported in #604849).
Note: See TracTickets for help on using tickets.