fork(2) download
  1. #include <iostream>
  2. #include <cassert>
  3.  
  4. using namespace std;
  5.  
  6. using uint = unsigned int;
  7.  
  8. struct Array { uint length; };
  9.  
  10. void test1() {
  11. cout << "test1" << endl;
  12.  
  13. Array array = {1000};
  14. uint startIndex = 100;
  15. uint length = 0xFFFFFFF0;
  16.  
  17. assert(0 <= startIndex && startIndex + length <= array.length);
  18.  
  19. cout << "array.length = " << array.length << endl
  20. << "startIndex = " << startIndex << endl
  21. << "length = " << length << endl
  22. << "startIndex + length = " << (startIndex + length) << endl;
  23.  
  24. }
  25.  
  26. void test2() {
  27. cout << "test2" << endl;
  28.  
  29. Array array = {1000};
  30. uint startIndex = 0xFFFFFFF0;
  31. uint length = 100;
  32.  
  33. assert(0 <= startIndex && startIndex + length <= array.length);
  34.  
  35. cout << "array.length = " << array.length << endl
  36. << "startIndex = " << startIndex << endl
  37. << "length = " << length << endl
  38. << "startIndex + length = " << (startIndex + length) << endl;
  39.  
  40. }
  41.  
  42.  
  43. int main() {
  44. test1();
  45. test2();
  46. return 0;
  47. }
Success #stdin #stdout 0s 4280KB
stdin
Standard input is empty
stdout
test1
array.length = 1000
startIndex = 100
length = 4294967280
startIndex + length = 84
test2
array.length = 1000
startIndex = 4294967280
length = 100
startIndex + length = 84