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

#11546: Compiler warning: cast from pointer to integer of different size -------------------------------------+------------------------------------- Reporter: wereHamster | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- While building the stage1 compiler: {{{ In file included from rts/Capability.h:25:0, from includes/dist-derivedconstants/header/tmp.c:15: rts/Task.h: In function 'serialiseTaskId': rts/Task.h:318:12: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] return (TaskId) taskID; ^ }}} I'm building a cross-compiler with build/host=x86_64-linux-gnu and target =mips-unknown-linux-musl -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11546 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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
participants (1)
-
GHC