[GHC] #15696: Derived Ord instance for enumerations with more than 8 elements seems to be incorrect

GHC ghc-devs at haskell.org
Thu Oct 11 22:24:20 UTC 2018


#15696: Derived Ord instance for enumerations with more than 8 elements seems to be
incorrect
-------------------------------------+-------------------------------------
        Reporter:  mrkkrp            |                Owner:  osa1
            Type:  bug               |               Status:  patch
        Priority:  highest           |            Milestone:  8.6.2
       Component:  Compiler          |              Version:  8.6.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Incorrect result  |  Unknown/Multiple
  at runtime                         |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #14677, #15155    |  Differential Rev(s):  Phab:D5196,
       Wiki Page:                    |  Phab:D5201
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Sorry, yes, I was looking in the wrong tree re (1) and (2).

 Re (3) I now understand. The output of the simplifier is this
 {{{
         $j_s6vr
           = case w_s75u of lwild_s6yB {
               __DEFAULT ->
                 case GHC.Prim.dataToTag# @ ClosureType lwild_s6yB of {
 __DEFAULT ->
                 case lwild_s6yB of lwild_s6yA {
                   __DEFAULT ->
                     case GHC.Prim.dataToTag# @ ClosureType lwild_s6yA of {
 __DEFAULT ->
                     case lwild_s6yA of lwild_s6vm {
                       __DEFAULT ->
                         case GHC.Prim.dataToTag# @ ClosureType lwild_s6vm
 of { __DEFAULT ->
                         1#
                         };
                       AP_STACK -> 2#
                     }
                     };
                   AP -> 2#
                 }
                 };
               THUNK_SELECTOR -> 2#
             } } in
 }}}
 Are those `case lwild_s6yB of lwild_s6yq { ...}` evals actually redundant?
 No: they
 are checking for `AP_STACK` and `THUNK_SELECTOR` resp.

 But the one you originally asked about was
 {{{
   case a#_a4k2 :: Int# of a#_X4Mq { __DEFAULT -> 1# }
 }}}
 This one was ''introduced'' by CSE, so it has not yet had a simplifer run
 to eliminate it. Before CSE it looked
 like
 {{{
   case dataToTag# lwild of a#_X4Mq { __DEFAULT -> 1# }
 }}}
 In short, all is well.  Just do (4).

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15696#comment:75>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list