
#12849: hsc2hs trouble with floating-point constants in cross-compilation mode -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: hsc2hs | Version: 7.8.4 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by rwbarton): I did some experiments with {{{ gcc (Debian 5.3.1-6) 5.3.1 20160114 }}} which also has this issue and {{{ Debian clang version 3.6.2-3 (tags/RELEASE_362/final) (based on LLVM 3.6.2) }}} which does not. There seems to be a class of what appear to be constant expressions involving floating-point constants which has the following behavior: * If used as the size of a local static array, gcc gives an error like `storage size of ‘x’ isn’t constant`. * If used as the size of a global array, gcc gives a ''warning'' `variably modified ‘x’ at file scope`. But it's not fatal, and clearly gcc must know the actual size of the array. Very strange! (If the size of a global array is not a constant expression at all, then gcc gives the same message but as an ''error''.) The simplest example of such an expression I found was `(int)(1.0 + 1)`. Clang seems to have no problem with floating-point numbers in constant expressions. So, if we can switch to use global arrays instead of local static arrays for the tests, and ignore these `variably modified` warnings from gcc, we should be able to handle constant expressions involving floating-point numbers correctly. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12849#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler