fork(2) download
  1. #include <iostream>
  2.  
  3. //#include <xmmintrin.h>
  4. typedef float __m128 __attribute__ ((vector_size (16)));
  5.  
  6.  
  7. class A {
  8. public:
  9. long double a;
  10. __m128 m;
  11. long long b;
  12. A() : a(1.3), b(123) {}
  13. };
  14.  
  15. char buffer[64];
  16.  
  17. template <class T>
  18. struct BA {
  19. char a[sizeof(T)];
  20. bool taken;
  21. BA* next;
  22. }__attribute__ ((aligned(__alignof(T))));
  23.  
  24. int main() {
  25. A* a = new (buffer + 1) A();
  26. #define PRINTT(a) std::cout << #a ": " << a << std::endl;
  27. PRINTT((void*)a);
  28. PRINTT((void*)(buffer + 1));
  29. PRINTT(sizeof(A));
  30. PRINTT(__alignof(A));
  31. if (__alignof(A) > 0)
  32. PRINTT(size_t(buffer + 1) % __alignof(A));
  33. PRINTT(a->a);
  34. PRINTT(a->b);
  35.  
  36. A b = *a;
  37. PRINTT(b.a);
  38. PRINTT(b.b);
  39.  
  40. a->~A();
  41.  
  42. PRINTT(__alignof(char));
  43. PRINTT(__alignof(int));
  44. PRINTT(__alignof(int*));
  45. PRINTT(__alignof(int (A::*)()));
  46. PRINTT(__alignof(long double));
  47. PRINTT(__alignof(long long));
  48. PRINTT(sizeof(BA<A>));
  49. PRINTT(__alignof(BA<A>));
  50. PRINTT(offsetof(BA<A>,a));
  51. PRINTT(offsetof(BA<A>,taken));
  52. PRINTT(offsetof(BA<A>,next));
  53. }
Success #stdin #stdout 0.01s 2728KB
stdin
Standard input is empty
stdout
(void*)a: 0x804b101
(void*)(buffer + 1): 0x804b101
sizeof(A): 48
__alignof(A): 16
size_t(buffer + 1) % __alignof(A): 1
a->a: 1.3
a->b: 123
b.a: 1.3
b.b: 123
__alignof(char): 1
__alignof(int): 4
__alignof(int*): 4
__alignof(int (A::*)()): 4
__alignof(long double): 4
__alignof(long long): 8
sizeof(BA<A>): 64
__alignof(BA<A>): 16
offsetof(BA<A>,a): 0
offsetof(BA<A>,taken): 48
offsetof(BA<A>,next): 52