Opened 2 years ago

Closed 2 years ago

#5603 closed bug (fixed)

Impossible case alternative

Reported by: igloo Owned by: simonpj
Priority: highest Milestone: 7.4.1
Component: Compiler Version: 7.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty:
Test Case: simplCore/should_run/T5603 Blocked By:
Blocking: Related Tickets:

Description

With q.hs:

{-# LANGUAGE MagicHash, UnboxedTuples, UnliftedFFITypes #-}

module Main (main) where

import GHC.Base
import GHC.Integer.GMP.Internals

main :: IO ()
main = (encodeDouble 0 :: Double) `seq` return ()

{-# INLINE encodeDouble #-}
encodeDouble :: Integer -> Double
encodeDouble (S# _)   = D# 3.0##
encodeDouble (J# _ _) = D# 4.0##

with the HEAD I get:

$ ghc --make q -O -dcore-lint -dcmm-lint
[1 of 1] Compiling Main             ( q.hs, q.o )
Linking q ...
$ ./q
q: Impossible case alternative

Change History (7)

comment:1 Changed 2 years ago by igloo

  • Test Case set to T5603

comment:2 Changed 2 years ago by daniel.is.fischer

I get that also with 7.3.20111002 and 7.3.20110926, with or without optimisations, so it's been around for a while.

comment:3 Changed 2 years ago by daniel.is.fischer

Might have something to do with Safe Haskell:

==================== FINAL INTERFACE ====================
interface main:Main 70320111104
  interface hash: dde4d932dd7e5dcabe2429697bb72b53
  ABI hash: 060fb3544313b988bbb91e59b614d122
  export-list hash: b2db2ff8c639b3c46c1322f9a70b23cd
  orphan hash: 693e9af84d3dfcc71e640e005bdc5e2e
  used TH splices: False
  where
exports:
  Main.main
module dependencies:
package dependencies: base ghc-prim integer-gmp
orphans: base:GHC.Base base:GHC.Float base:Text.Read.Lex
family instance modules: base:Data.Either base:Data.Maybe
                         ghc-prim:GHC.Generics ghc-prim:GHC.Tuple
import safe base:GHC.Base 6997be94949bcf79c273866dbf21bd74
import safe base:Prelude 2d51f353e8baccd6fe45deb0590d3064
import safe ghc-prim:GHC.Types e7a4b8ccaa1476f33a832341dbabb58f
import safe integer-gmp:GHC.Integer.GMP.Internals dd3c71d5d955840824090bf063c0d2f2
import safe integer-gmp:GHC.Integer.Type 710490b06d830cde12db7b3b435cebb9
ac754e52bd8b0218f7502181f47a21a4

import safe base:GHC.Base sure looks fishy, and 7.2.1 says

==================== FINAL INTERFACE ====================
interface main:Main 7021
  interface hash: 99423326fc6440c75738cb322290a2d7
  ABI hash: f716d21202bfc2cd2f1894b53d3d4da6
  export-list hash: 91221ade6b57b319378a1225281bb6b9
  orphan hash: 693e9af84d3dfcc71e640e005bdc5e2e
  used TH splices: False
  where
exports:
  Main.main
module dependencies:
package dependencies: base ghc-prim integer-gmp
orphans: base:GHC.Base base:GHC.Float base:GHC.Num
family instance modules: base:Data.Either base:Data.Maybe
                         ghc-prim:GHC.Ordering ghc-prim:GHC.Tuple ghc-prim:GHC.Types
                         ghc-prim:GHC.Unit
import  -/  base:GHC.Base 8faff928893671eff07da1e49d208761
import  -/  base:Prelude 292ea38da78228a142de16a2b4594082
import  -/  ghc-prim:GHC.Types 782ea676905837bb481c02595e678205
import  -/  integer-gmp:GHC.Integer.GMP.Internals 4dd5cbecca9166b46f29fdf796a8b488
import  -/  integer-gmp:GHC.Integer.Type 1586bb2165fc529b96ade91209cd4c84
fdf2a684a14eb4c7b2a45b9babeb8722

comment:4 Changed 2 years ago by daniel.is.fischer

No, it's not that. Works if the Integer to encode isn't known at compile time.

comment:5 Changed 2 years ago by simonpj

  • Owner set to simonpj

I know what is going on here. I probably won't get to it till next week though. Thanks for the example.

Simon

comment:6 Changed 2 years ago by simonpj@…

commit f96db3ca8a7c83cc3da242fad761fb05543068f6

Author: Simon Peyton Jones <simonpj@microsoft.com>
Date:   Wed Nov 9 23:32:20 2011 +0000

    Establish the invariant that (LitAlt l) is always unlifted
    
    ...and make sure it is, esp in the call to findAlt in
    the mighty Simplifier.  Failing to check this led to
    searching a bunch of DataAlts for a LitAlt Integer.
    Naughty.  See Trac #5603 for a case in point.

 compiler/basicTypes/Literal.lhs    |    6 +++++-
 compiler/coreSyn/CoreLint.lhs      |   13 ++++++-------
 compiler/coreSyn/CoreSyn.lhs       |   30 +++++++++++++++++++++++++-----
 compiler/deSugar/DsUtils.lhs       |    8 +++++---
 compiler/prelude/PrelRules.lhs     |    3 +++
 compiler/simplCore/Simplify.lhs    |    2 ++
 compiler/specialise/SpecConstr.lhs |    4 +++-
 7 files changed, 49 insertions(+), 17 deletions(-)

comment:7 Changed 2 years ago by simonpj

  • Resolution set to fixed
  • Status changed from new to closed
  • Test Case changed from T5603 to simplCore/should_run/T5603
Note: See TracTickets for help on using tickets.