[GHC] #11546: Compiler warning: cast from pointer to integer of different size

GHC ghc-devs at haskell.org
Sat Apr 9 17:28:08 UTC 2016


#11546: Compiler warning: cast from pointer to integer of different size
-------------------------------------+-------------------------------------
        Reporter:  wereHamster       |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:
      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 wereHamster):

 The cast is from OSThreadId (pthread_t) to TaskId (StgWord64). Musl
 defines the former as `TYPEDEF struct __pthread * pthread_t`.

 pthread_t is not required to be an arithmetic type (it can be a struct),
 so musl does not violate POSIX (see
 http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html,
 scroll to the very bottom, Issue 6).

 Alternatives:

  - Cast to (size_t) first, just like in the case of
 `defined(freebsd_HOST_OS) || defined(darwin_HOST_OS)` (see the
 implementation of the serialiseTaskId function). A dirty solution which
 may not work on platforms where pthread_t truly is a struct and not a
 pointer/integer.
  - Make TaskId a type alias for OSThreadId (because AFAICS the two are
 equal).
  - Allocate our own (numeric) Thread Ids and store them in TLS (on POSIX
 platforms), to be independent of the implementation of pthread_t.
  - Simply give up on platforms where pthread_t is not an alias for an
 arithmetic type (probably difficult to detect at compile / configure
 time).

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


More information about the ghc-tickets mailing list