This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

mt_allocator.cc assumes sizeof(size_t) == sizeof(void *)


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.sherrill@OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]