Skip to content

Commit 726195a

Browse files
committed
Make MSVC conform to standard new throwing behaviour
Add /Zc:throwingNew so the compiler won't pointlessly generate null checks for allocations. new has been defined to throw on failure since C++98 and MSVC has implemented that since after version 6.0, but for backwards compatibility reasons they still insert null checks. We don't need that, we live in the future and use at least C++17, we can assume that new throws rather than return nullptr on error. This makes the MSVC build behave more like clang and gcc which is nice, the fewer differences between environments the better.
1 parent 0719d9e commit 726195a

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

cmake/Macros.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ function(tgui_set_global_compile_flags target)
5454
/Zc:__cplusplus
5555
/Zc:preprocessor
5656
/Zc:inline
57+
/Zc:throwingNew
5758
)
5859
else()
5960
target_compile_options(${target} PRIVATE

0 commit comments

Comments
 (0)