From 2582123b91b61d0de6ae060e6d5e473349b25063 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 26 Oct 2023 11:23:06 -0700 Subject: [PATCH] Fix LTO runs of test_nothrow_new_nogrow This test was recently added in #20154 but has been failing on the emscripten-releases waterfall in thinlto modes. I'm not sure exactly why, but it seems that perhaps when the value of `data` is not actually thinLTO simple removes the call the new/malloc? I'm not sure why this wasn't also failing under full LTO. --- test/core/test_nothrow_new.cpp | 18 +++++++----------- test/core/test_nothrow_new.out | 1 + 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/test/core/test_nothrow_new.cpp b/test/core/test_nothrow_new.cpp index eb3c195d403c3..4f1a7334dcb1e 100644 --- a/test/core/test_nothrow_new.cpp +++ b/test/core/test_nothrow_new.cpp @@ -3,18 +3,14 @@ // University of Illinois/NCSA Open Source License. Both these licenses can be // found in the LICENSE file. -#include +#include +#include #include -char* data; - int main() { - data = new (std::nothrow) char[20 * 1024 * 1024]; - if (data == nullptr) { - std::cout << "success" << std::endl; - return 0; - } else { - std::cout << "failure" << std::endl; - return 1; - } + char* data = new (std::nothrow) char[20 * 1024 * 1024]; + printf("data: %p\n", data); + assert(data == nullptr); + printf("success\n"); + return 0; } diff --git a/test/core/test_nothrow_new.out b/test/core/test_nothrow_new.out index 2e9ba477f89e8..dee5a560282b5 100644 --- a/test/core/test_nothrow_new.out +++ b/test/core/test_nothrow_new.out @@ -1 +1,2 @@ +data: 0 success