From 566bebf2d53f447c541d4b4ca5616b34d7d37616 Mon Sep 17 00:00:00 2001 From: Ilya Eremin Date: Thu, 26 Dec 2024 14:38:50 +0300 Subject: [PATCH] Make return-type a compilation error (#8362) This protects from undefined behavior cases that can be added to the code by mistake. --- builds/posix/make.defaults | 2 +- builds/win32/msvc15/FirebirdCommon.props | 1 + src/common/CvtFormat.cpp | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/builds/posix/make.defaults b/builds/posix/make.defaults index 3c28683f6f..e41232b18b 100755 --- a/builds/posix/make.defaults +++ b/builds/posix/make.defaults @@ -111,7 +111,7 @@ GLOB_OPTIONS:= #____________________________________________________________________________ # Global c++ flags: firebird needs no RTTI, choose build standard and c++ specific warnings level -PLUSPLUS_FLAGS:= -fno-rtti -std=c++17 -Werror=delete-incomplete +PLUSPLUS_FLAGS:= -fno-rtti -std=c++17 -Werror=delete-incomplete -Werror=return-type # If this is defined then we use special rules useful for developers only IsDeveloper = @DEVEL_FLG@ diff --git a/builds/win32/msvc15/FirebirdCommon.props b/builds/win32/msvc15/FirebirdCommon.props index 617e13a39b..18bf022691 100644 --- a/builds/win32/msvc15/FirebirdCommon.props +++ b/builds/win32/msvc15/FirebirdCommon.props @@ -28,6 +28,7 @@ false true _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + 4715 true diff --git a/src/common/CvtFormat.cpp b/src/common/CvtFormat.cpp index 92c303cd15..1e89c09c8c 100644 --- a/src/common/CvtFormat.cpp +++ b/src/common/CvtFormat.cpp @@ -1124,6 +1124,7 @@ namespace return twelveHours == 12 ? twelveHours : 12 + twelveHours; cb->err(Arg::Gds(isc_incorrect_hours_period) << string(period.data(), period.length())); + return 0; // suppress compiler warning/error } constexpr int roundYearPatternImplementation(int parsedRRValue, int currentYear)