fork download
  1. #include <stdio.h>
  2.  
  3. struct bytes10
  4. {
  5. ~bytes10() { printf("dtor %p", this); }
  6. char _[10];
  7. };
  8.  
  9. int main()
  10. {
  11. size_t size1 = ((size_t*)new int[10])[-1];
  12. printf("%zu (0x%zx)\n", size1, size1);
  13. printf("%zu\n", ((size_t*)new bytes10[5])[-1]);
  14. printf("%zu\n", ((size_t*)new bytes10[6])[-1]);
  15. printf("%zu\n", ((size_t*)new bytes10[7])[-1]);
  16. printf("%zu\n", ((size_t*)new bytes10[65536])[-1]);
  17. return 0;
  18. }
Success #stdin #stdout 0s 5524KB
stdin
Standard input is empty
stdout
49 (0x31)
5
6
7
65536