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

Started by
3 comments, last by matt77hias 6 years, 4 months ago

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

🧙

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.

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 .

🧙

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 ;)

🧙

This topic is closed to new replies.

Advertisement