• Advertisement
Sign in to follow this  

warning C4316: object allocated on the heap may not be aligned 16

Recommended Posts

When I run my x86 builds, I get some "warning C4316: object allocated on the heap may not be aligned 16"?

How is this possible given that I use alignas and /std::C++latest in MVC++ (which should at least be C++17)?

 

Edit: Hmm apparantly I like to walk on the wild side :D

https://docs.microsoft.com/en-us/cpp/visual-cpp-language-conformance

 P0035R4 Over-aligned dynamic memory allocation    VS 2017 15.5

Edited by matt77hias

Share this post


Link to post
Share on other sites
Advertisement
17 minutes ago, turanszkij said:

I remember having problems with this on x86 builds (though it was some time ago). I think I could solve it with creating an explicit the new operator with a call to _mm_malloc or _aligned_malloc, and _mm_free delete operators.

Idd. that works fine. Originally, I did this as well, but then I removed this for C++17's alignas support. I falsely assumed that the MVC++ compiler team already included it as it seems one of the more trivial C++17 features and since MSDN does not mention the word alignas once in their conformance table :o .

Share this post


Link to post
Share on other sites
3 hours ago, turanszkij said:

I remember having problems with this on x86 builds (though it was some time ago). I think I could solve it with creating an explicit the new operator with a call to _mm_malloc or _aligned_malloc, and _mm_free delete operators.

FYI, the VS gods have heard my prayers: VS 2017 15.5 is available. C++11 alignas becomes C++17 alignas ;)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Advertisement