Hello, I have to apologize because I've fooled myself. Everything works fine in the Haskell side. The problem was that I tried to pass a float value to printf which is a variadic C function. According to the C standard / stack overflow:
> * because printf and its friends are variadic functions, so a float > parameter undergoes automatic conversion to double as part of the default > argument promotions (see section 6.5.2.2 of the C99 standard).* > Sorry for the confusion. Thanks, Csaba On Wed, Jan 22, 2020 at 10:27 PM Csaba Hruska <[email protected]> wrote: > I added Stg and Cmm linter to my custom pipeline and they report no errors. > > On Wed, Jan 22, 2020 at 4:40 PM Csaba Hruska <[email protected]> > wrote: > >> Here are the pretty printed STG in GHC syntax: >> >> *WORKING (DoubleRep): prints 3.14* >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> *x0 :: Any[GblId] = "Value: MyConA %d %d\n"#;x1 :: Any[GblId] = >> "Value: MyConB %lf\n"#;main :: Any[GblId] = [] \u [void_0E] case >> MyConB [3.14##] of x100 { __DEFAULT -> case x100 of >> x101 { MyConA x200 x202 -> __pkg_ccall [x0 x200 x202]; >> MyConB x203 -> __pkg_ccall [x1 x203]; }; };* >> >> >> *WRONG (FloatRep) : prints 0.00 instead of 3.14* >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> *x0 :: Any[GblId] = "Value: MyConA %d %d\n"#;x1 :: Any[GblId] = >> "Value: MyConB %f\n"#;main :: Any[GblId] = [] \u [void_0E] case >> MyConB [3.14#] of x100 { __DEFAULT -> case x100 of >> x101 { MyConA x200 x202 -> __pkg_ccall [x0 x200 x202]; >> MyConB x203 -> __pkg_ccall [x1 x203]; }; };* >> Thanks, >> Csaba >> >> On Wed, Jan 22, 2020 at 4:21 PM Csaba Hruska <[email protected]> >> wrote: >> >>> Sorry, I should have noted that the gist has a description comment at >>> the bottom. >>> >>> https://gist.github.com/csabahruska/e9e143390c863f7b10b0298a7ae80ac1#gistcomment-3148797 >>> >>> >>> On Wed, Jan 22, 2020 at 3:21 PM Ömer Sinan Ağacan <[email protected]> >>> wrote: >>> >>>> What is the problem you're having? What do you mean by "run into >>>> problems"? >>>> What's going wrong? >>>> >>>> It'd be helpful if you could show us your program in STG syntax. >>>> >>>> > Is it valid to use FloatRep argument in a boxed ADT on 64 bit? >>>> >>>> It should be valid, yes. >>>> >>>> I'd also try with `-dstg-lint -dcmm-lint`. >>>> >>>> Ömer >>>> >>>> Csaba Hruska <[email protected]>, 22 Oca 2020 Çar, 14:56 >>>> tarihinde şunu yazdı: >>>> > >>>> > Hello, >>>> > >>>> > I try to use GHC backend via STG. For that reason I build small STG >>>> program AST maually. So far the generated programs worked fine >>>> (compile/link/run). >>>> > However I run into problems when a lifted ADT has a FloatRep argument. >>>> > Interestingly it works for DoubleRep. >>>> > I'm using GHC 8.6.1 64 bit to generate the code for the constructed >>>> STG AST. >>>> > I wonder if I break an invariant or is this actually a bug? >>>> > Is it valid to use FloatRep argument in a boxed ADT on 64 bit? >>>> > I made a gist with the Haskell source and the generated Cmm code is >>>> also included. >>>> > >>>> > https://gist.github.com/csabahruska/e9e143390c863f7b10b0298a7ae80ac1 >>>> > >>>> > Working program (DoubleRep): >>>> > >>>> https://gist.github.com/csabahruska/e9e143390c863f7b10b0298a7ae80ac1#file-stgsample-hs-L134-L198 >>>> > >>>> > Wrong program (FloatRep): >>>> > >>>> https://gist.github.com/csabahruska/e9e143390c863f7b10b0298a7ae80ac1#file-stgsample-hs-L64-L132 >>>> > >>>> > Thanks, >>>> > Csaba >>>> > >>>> > >>>> > _______________________________________________ >>>> > ghc-devs mailing list >>>> > [email protected] >>>> > http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs >>>> >>>
_______________________________________________ ghc-devs mailing list [email protected] http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
