Jump to content
  • Advertisement
Sign in to follow this  
matt77hias

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

This topic is 374 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

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.

Share this post


Link to post
Share on other sites
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!