fail_allocate.carbon 754 B

1234567891011121314151617181920
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // NOAUTOUPDATE
  6. // RUN: %{not} %{explorer-run}
  7. // CHECK:STDERR: RUNTIME ERROR: overflow:1: Possible infinite loop: too many interpreter steps executed
  8. package EmptyIdentifier impl;
  9. fn Main() -> i32 {
  10. while (true) {
  11. // Ideally we would hit an OOM here, but it's too difficult to OOM from heap
  12. // allocations before hitting max steps. Maybe with string operations we
  13. // could trigger actual excessive memory allocations by just doubling the
  14. // size of the string each time.
  15. heap.New((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0));
  16. }
  17. return 0;
  18. }