For any object type T is it always the case that sizeof(T) is at least as large as alignof(T)?
Intuitively it seems so, since
#include
typedef double foo __attribute__ ((aligned (64)));
alignas(64) double bar;
double baz __attribute__ ((aligned (64)));
int main(int argc, char *argv[]) {
std::cout << "foo sizeof: " << sizeof(foo) << " alignof: " << alignof(foo) << "\n";
std::cout << "bar sizeof: " << sizeof(bar) << " alignof: " << alignof(decltype(bar)) << "\n";
std::cout << "baz sizeof: " << sizeof(baz) << " alignof: " << alignof(decltype(baz)) << "\n";
}
Compile with:
clang++ -std=c++11 alignof_test.cpp -o alignof_test && ./alignof_test
Output:
foo sizeof: 8 alignof: 64
bar sizeof: 8 alignof: 8
baz sizeof: 8 alignof: 8
So strictly speaking, no, but the above argument re: arrays has to be preserved.