fork download
  1. #include <iostream>
  2.  
  3. struct C
  4. {
  5. char x[8];
  6. char y;
  7. };
  8.  
  9.  
  10. struct D
  11. {
  12. alignas(8) char x[8];
  13. char y;
  14. };
  15.  
  16. int main() {
  17. std::cout << "C: " << sizeof(C) << " " << alignof(C) << "\n";
  18. std::cout << "D: " << sizeof(D) << " " << alignof(D) << "\n";
  19. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
C: 9 1
D: 16 8