Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interlocked compile errors in C++ on Windows #83

seanmiddleditch opened this issue Jul 7, 2019 · 2 comments


None yet
2 participants
Copy link

commented Jul 7, 2019

Setting MI_USE_CXX to ON and compiling with MSC (latest version in 16.1.5 / 2019.1) a number of instances of this error occur:

C:\Users\Sean\Documents\Projects\test\mimalloc-src\include\mimalloc-atomic.h(68): error C2665: '_InterlockedIncrement': none of the 4 overloads could convert all the argument types
  C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um\winbase.h(9283): note: could be 'unsigned __int64 _InterlockedIncrement(volatile unsigned __int64 *)'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um\winbase.h(9271): note: or       'unsigned long _InterlockedIncrement(volatile unsigned long *)'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um\winbase.h(9262): note: or       'unsigned int _InterlockedIncrement(volatile unsigned int *)'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um\winnt.h(2954): note: or       'LONG _InterlockedIncrement(volatile LONG *)'

I haven't dug too deep, but looking in the Win10 SDK's copy of WinBase.h I'm only seeing overloads for unsigned types. This issue might then be more of an issue with the Win10 SDK and not actually the compiler, though I didn't get these errors when compiling with the C compiler.

There's also a few instances of:

C:\Users\Sean\Documents\Projects\test\mimalloc-src\src\alloc.c(114): error C2679: binary '=': no operator found which takes a right-hand operand of type 'volatile mi_thread_free_t' (or there is no acceptable conversion)
  C:\Users\Sean\Documents\Projects\test\mimalloc-src\include\mimalloc-types.h(142): note: could be 'mi_thread_free_u &mi_thread_free_u::operator =(mi_thread_free_u &&)'
  C:\Users\Sean\Documents\Projects\test\mimalloc-src\include\mimalloc-types.h(142): note: or       'mi_thread_free_u &mi_thread_free_u::operator =(const mi_thread_free_u &)'
  C:\Users\Sean\Documents\Projects\test\mimalloc-src\src\alloc.c(114): note: while trying to match the argument list '(mi_thread_free_t, volatile mi_thread_free_t)'

All of these look like issues with (missing) volatile reference overloads in mimalloc C++ wrappers, I think, though I haven't really looked into this one at all.


This comment has been minimized.

Copy link

commented Jul 8, 2019

Thanks! The second set of instances are fixed in the latest dev branch. I need to look into the interlocked ones further. Note that using MI_USE_CXX=ON is not needed -- the generated libraries are always usable from both C and C++. Hope this helps!


This comment has been minimized.

Copy link

commented Jul 8, 2019

Fixed in the latest dev branch.

@daanx daanx closed this Jul 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.