[GHC] #12636: ProfHeap's printf modifiers are incorrect

GHC ghc-devs at haskell.org
Sat Feb 11 09:37:55 UTC 2017


#12636: ProfHeap's printf modifiers are incorrect
-------------------------------------+-------------------------------------
        Reporter:  Phyx-             |                Owner:  bollu
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Runtime System    |              Version:  8.0.1
      Resolution:                    |             Keywords:  newcomer
Operating System:  Windows           |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by bollu):

 Why does the `Census` type `ssize_t` for `void_total`, `drag_total`, etc?
 wouldn't `size_t` be more appropriate, as they don't seem to be using the
 _signed_ property of `ssize_t`?

 The piece of code that causes the warning is

 {{{
         fprintf(hp_file, "LAG\t%lu\n",
                 (unsigned long)(census->not_used - census->void_total) *
 sizeof(W_));
 }}}

 The `sizeof(W_) :: size_t` and `census->not_used :: ssize_t`.

 The solution that I'm proposing is to cast the `ssize_t` to a `size_t` and
 then change the format specifier to `%zu` as discussed on StackOverflow:

 [http://stackoverflow.com/questions/2125845/platform-independent-size-t
 -format-specifiers-in-c]

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


More information about the ghc-tickets mailing list