Attached is a patch which changes size_t to uintptr_t. It is enough to let the build continue. But I would appreciate feedback given the code.
--joel On 11/7/2014 9:07 AM, Joel Sherrill wrote: > Hi > > On m32c-rtems, we have a build error in C++ because size_t > is 16-bits and pointers are 24 bits. m32c-elf probably does not > enable __GTHREAD support like rtems does. Since this is code > shared across targets, what is the best way to fix this? > > My first inclination would be to use uintptr_t for the variable > _M_id but I don't know what other impacts that would have > or where else this needs to be fixed. > > ../../../../../../gcc/libstdc++-v3/src/c++98/mt_allocator.cc: In > function 'void {anonymous}::_M_destroy_thread_key(void*)': > ../../../../../../gcc/libstdc++-v3/src/c++98/mt_allocator.cc:77:51: > error: cast from 'void*' to 'size_t {aka unsigned int}' loses precision > [-fpermissive] > size_t _M_id = reinterpret_cast<size_t>(__id); > ^ > ../../../../../../gcc/libstdc++-v3/src/c++98/mt_allocator.cc: In member > function 'std::size_t __gnu_cxx::__pool<true>::_M_get_thread_id()': > ../../../../../../gcc/libstdc++-v3/src/c++98/mt_allocator.cc:630:25: > error: cast from 'void*' to 'std::size_t {aka unsigned int}' loses > precision [-fpermissive] > size_t _M_id = (size_t)v; > ^ > ../../../../../../gcc/libstdc++-v3/src/c++98/mt_allocator.cc:643:52: > warning: cast to pointer from integer of different size > [-Wint-to-pointer-cast] > __gthread_setspecific(freelist._M_key, (void*)_M_id); > ^ > Thanks. > -- Joel Sherrill, Ph.D. Director of Research & Development joel.sherr...@oarcorp.com On-Line Applications Research Ask me about RTEMS: a free RTOS Huntsville AL 35805 Support Available (256) 722-9985
diff --git a/gcc/expr.c b/gcc/expr.c index 203e28f..b25396d 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -715,12 +715,14 @@ convert_modes (machine_mode mode, machine_mode oldmode, rtx x, int unsignedp) if (mode == oldmode) return x; - if (CONST_SCALAR_INT_P (x) && GET_MODE_CLASS (mode) == MODE_INT) + if (CONST_SCALAR_INT_P (x) && (GET_MODE_CLASS (mode) == MODE_INT + || GET_MODE_CLASS (mode) == MODE_PARTIAL_INT)) { /* If the caller did not tell us the old mode, then there is not much to do with respect to canonicalization. We have to assume that all the bits are significant. */ - if (GET_MODE_CLASS (oldmode) != MODE_INT) + if (GET_MODE_CLASS (oldmode) != MODE_INT + && GET_MODE_CLASS (oldmode) != MODE_PARTIAL_INT) oldmode = MAX_MODE_INT; wide_int w = wide_int::from (std::make_pair (x, oldmode), GET_MODE_PRECISION (mode), diff --git a/libstdc++-v3/src/c++98/mt_allocator.cc b/libstdc++-v3/src/c++98/mt_allocator.cc index 38e17df..828ca82 100644 --- a/libstdc++-v3/src/c++98/mt_allocator.cc +++ b/libstdc++-v3/src/c++98/mt_allocator.cc @@ -74,7 +74,7 @@ namespace __freelist& freelist = get_freelist(); { __gnu_cxx::__scoped_lock sentry(get_freelist_mutex()); - size_t _M_id = reinterpret_cast<size_t>(__id); + uintptr_t _M_id = reinterpret_cast<uintptr_t>(__id); typedef __gnu_cxx::__pool<true>::_Thread_record _Thread_record; _Thread_record* __tr = &freelist._M_thread_freelist_array[_M_id - 1]; @@ -627,7 +627,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { __freelist& freelist = get_freelist(); void* v = __gthread_getspecific(freelist._M_key); - size_t _M_id = (size_t)v; + uintptr_t _M_id = (uintptr_t)v; if (_M_id == 0) { {