From 13ccf5caa6b091ddc6a743ab47a6541ea1003554 Mon Sep 17 00:00:00 2001 From: Ilya Eremin Date: Wed, 25 Dec 2024 12:27:39 +0300 Subject: [PATCH] Make return-type a compilation error 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 3c28683f6f8..e41232b18b5 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 617e13a39b6..18bf022691d 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 92c303cd151..1e89c09c8c0 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)