dvyukov / relacy

Automatically exported from code.google.com/p/relacy
Other
209 stars 32 forks source link

change hash_map_t key type for gcc v8 #12

Closed cengiz-io closed 2 years ago

cengiz-io commented 5 years ago

Hello!

I didn't know about relacy before. Will surely use it in the future.

While compiling with gcc version 8.2.1 on Linux, GNU libc 2.28, I've encountered following errors:

error: static assertion failed: std::map must have the same value_type as its allocator

/usr/include/c++/8.2.1/bits/stl_map.h: In instantiation of ‘class std::map<const void*, long unsigned int, std::less<const void*>, rl::raw_allocator<std::pair<const void*, long unsigned int> > >’:
../subprojects/base_library/gitmodules/relacy/relacy/context_addr_hash.hpp:55:45:   required from here
/usr/include/c++/8.2.1/bits/stl_map.h:122:21: error: static assertion failed: std::map must have the same value_type as its allocator

Tried to fix them by swapping map<void const*, ...> keys to map<void* const, ...>. Not sure if this is the best we can do.

Thanks!

dvyukov commented 5 years ago

Hi Cengiz,

While I see people reference similar errors on internet, e.g.: https://github.com/JakobEngel/dso/issues/111 I can't reproduce this with gcc 7, 8 nor 9. Do you use any additional flags to build? Can you post complete reproducer?

I am not sure this is a correct change as we put const void* into the map. I wrote a test that actually uses this code: https://gist.githubusercontent.com/dvyukov/e9c8d4de38f228bb046879d7593182bb/raw/8066eb4cb4cbb180df4d8d5e95dd201be51c9424/gistfile1.txt And it build successfully for me with gcc 7/8 with c++11/14/gnu++11/14, but with your change it causes what looks like legitimate build errors: https://gist.githubusercontent.com/dvyukov/b2dad042ec5d0ce8c8031049dd62a7a6/raw/df44ca0388327231681358e26630eacd3560b92f/gistfile1.txt

cengiz-io commented 5 years ago

Hello,

I'll re-test this as soon as possible