[Git][ghc/ghc][master] Fix C output for modern C initiative

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Fri Feb 16 18:38:11 UTC 2024



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
1f534c2e by Florian Weimer at 2024-02-16T13:37:42-05:00
Fix C output for modern C initiative

GCC 14 on aarch64 rejects the C code written by GHC with this kind of
error:

   error: assignment to ‘ffi_arg’ {aka ‘long unsigned int’} from ‘HsPtr’ {aka ‘void *’} makes integer from pointer without a cast [-Wint-conversion]
         68 | *(ffi_arg*)resp = cret;
            |                 ^

Add the correct cast.

For more information on this see:
https://fedoraproject.org/wiki/Changes/PortingToModernC

Tested-by: Richard W.M. Jones <rjones at redhat.com>

- - - - -


1 changed file:

- compiler/GHC/HsToCore/Foreign/C.hs


Changes:

=====================================
compiler/GHC/HsToCore/Foreign/C.hs
=====================================
@@ -560,7 +560,7 @@ mkFExportCBits dflags c_nm maybe_target arg_htys res_hty is_IO_res_ty cc
      ,   ppUnless res_hty_is_unit $
          if libffi
                   then char '*' <> parens (ffi_cResType <> char '*') <>
-                       text "resp = cret;"
+                       text "resp = " <> parens ffi_cResType <> text "cret;"
                   else text "return cret;"
      , rbrace
      ]



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1f534c2e7388273e70534680212c1357614c11ed

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1f534c2e7388273e70534680212c1357614c11ed
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240216/4e3e3a4e/attachment.html>


More information about the ghc-commits mailing list