From 543b7fa6c2ff13ad8deb2f057f89f00bbb5e0cd1 Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Sat, 2 Aug 2025 22:52:20 -0400 Subject: [PATCH] Use `std::nothrow` for the only `new` expression Ideally we'd use `std::make_shared`, but it has insufficient compiler support for array types --- src/asm/lexer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/asm/lexer.cpp b/src/asm/lexer.cpp index 4111e7ad..082e9d4c 100644 --- a/src/asm/lexer.cpp +++ b/src/asm/lexer.cpp @@ -11,6 +11,7 @@ #include #include #include +#include // nothrow #include #include #include @@ -340,7 +341,7 @@ void LexerState::setFileAsNextState(std::string const &filePath, bool updateStat // Read the entire file for better performance // Ideally we'd use C++20 `auto ptr = std::make_shared(size)`, // but it has insufficient compiler support - auto ptr = std::shared_ptr(new char[size]); + auto ptr = std::shared_ptr(new (std::nothrow) char[size]); if (std::ifstream fs(path, std::ios::binary); !fs) { // LCOV_EXCL_START