Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

Alignment in x86 is Broken for Inheritance

$
0
0

Here is a simple program demonstrating the problem. Both "static_assert"s should pass, but only the first does.

//__declspec(align(16)) class Vec3 {}; //For testing purposes on Windows
//class Vec3 {} __attribute__((__aligned__(16))); //For testing purposes on *nix

class Base { public:
    Vec3 v;
};
class Child : public Base {};

static_assert(alignof( Base)>=16,"Check 1");
static_assert(alignof(Child)>=16,"Check 2");

Viewing all articles
Browse latest Browse all 1616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>