Skip to content

Commit

Permalink
Set -Werror=return-local-addr on Unix build
Browse files Browse the repository at this point in the history
Returning a reference to a temporary is such an obvious bug that I'm not sure
why compilers only treat it as a warning by default. This -W flag is tested on
Linux with G++, and might need changing for Clang.
  • Loading branch information
Matthew Mott committed Mar 31, 2021
1 parent 4141ee6 commit 2a79f63
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Expand Up @@ -7,6 +7,9 @@ project(darkradiant VERSION 2.11.0)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

# Global compiler options and warnings (TODO: may need updating for CLang)
add_compile_options(-Werror=return-local-addr)

# GCC 8 and earlier require explicit linking against stdc++fs
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9)
link_libraries(stdc++fs)
Expand Down

0 comments on commit 2a79f63

Please sign in to comment.