From 0a719e3081c10482a15bd95b5fbe3c8dc18ac3c3 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Wed, 14 Feb 2024 15:05:41 +0100 Subject: [PATCH] Xcode: turn on and resolve all warnings --- UnitTests/UnitTests.xcodeproj/project.pbxproj | 138 ++++++++++++++++-- UnitTests/hash.cpp | 4 +- UnitTests/main.cpp | 2 +- UnitTests/parser.cpp | 8 + UnitTests/ring.cpp | 9 +- include/stdex/compat.hpp | 3 +- include/stdex/hash.hpp | 2 + include/stdex/hex.hpp | 8 +- include/stdex/html.hpp | 16 +- include/stdex/locale.hpp | 9 ++ include/stdex/parser.hpp | 5 +- include/stdex/progress.hpp | 2 + include/stdex/sgml.hpp | 9 ++ include/stdex/socket.hpp | 2 +- include/stdex/stream.hpp | 3 +- include/stdex/string.hpp | 4 +- include/stdex/sys_info.hpp | 9 ++ include/stdex/unicode.hpp | 1 + 18 files changed, 197 insertions(+), 37 deletions(-) diff --git a/UnitTests/UnitTests.xcodeproj/project.pbxproj b/UnitTests/UnitTests.xcodeproj/project.pbxproj index ec5876e26..895194a78 100644 --- a/UnitTests/UnitTests.xcodeproj/project.pbxproj +++ b/UnitTests/UnitTests.xcodeproj/project.pbxproj @@ -275,35 +275,71 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_DEADCODE_DEADSTORES = YES; + CLANG_ANALYZER_DIVIDE_BY_ZERO = YES; + CLANG_ANALYZER_GCD = YES; + CLANG_ANALYZER_GCD_PERFORMANCE = YES; + CLANG_ANALYZER_LIBKERN_RETAIN_COUNT = YES; + CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = YES; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_ANALYZER_MEMORY_MANAGEMENT = YES; + CLANG_ANALYZER_MIG_CONVENTIONS = YES; CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NULL_DEREFERENCE = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_ANALYZER_OBJC_COLLECTIONS = YES; + CLANG_ANALYZER_OBJC_NSCFERROR = YES; + CLANG_ANALYZER_OSOBJECT_C_STYLE_CAST = YES; + CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_GETPW_GETS = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_MKSTEMP = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_UNCHECKEDRETURN = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_VFORK = YES; + CLANG_ANALYZER_SECURITY_KEYCHAIN_API = YES; + CLANG_ANALYZER_USE_AFTER_MOVE = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "c++17"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_STATIC_ANALYZER_MODE = deep; + CLANG_STATIC_ANALYZER_MODE_ON_ANALYZE_ACTION = deep; + CLANG_TIDY_BUGPRONE_ASSERT_SIDE_EFFECT = YES; + CLANG_TIDY_BUGPRONE_INFINITE_LOOP = YES; + CLANG_TIDY_BUGPRONE_MOVE_FORWARDING_REFERENCE = YES; + CLANG_TIDY_BUGPRONE_REDUNDANT_BRANCH_CONDITION = YES; + CLANG_TIDY_MISC_REDUNDANT_EXPRESSION = YES; + CLANG_WARN_ASSIGN_ENUM = YES; + CLANG_WARN_ATOMIC_IMPLICIT_SEQ_CST = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; + CLANG_WARN_COMPLETION_HANDLER_MISUSE = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_CXX0X_EXTENSIONS = YES; + CLANG_WARN_DELETE_NON_VIRTUAL_DTOR = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_FLOAT_CONVERSION = YES; + CLANG_WARN_FRAMEWORK_INCLUDE_PRIVATE_FROM_PUBLIC = YES; CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_PRAGMA_PACK = YES; + CLANG_WARN_PRIVATE_MODULE = YES; CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SEMICOLON_BEFORE_METHOD_BODY = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CLANG_WARN_VEXING_PARSE = YES; + CLANG_WARN__EXIT_TIME_DESTRUCTORS = YES; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -315,13 +351,31 @@ _DEBUG, "$(inherited)", ); + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; + GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES; + GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = YES; + GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; + GCC_WARN_ABOUT_MISSING_NEWLINE = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + GCC_WARN_ABOUT_POINTER_SIGNEDNESS = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; + GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; + GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; + GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; + GCC_WARN_MISSING_PARENTHESES = YES; + GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; + GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_LABEL = YES; + GCC_WARN_UNUSED_PARAMETER = YES; + GCC_WARN_UNUSED_VALUE = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ../include; MACOSX_DEPLOYMENT_TARGET = 10.15; @@ -329,6 +383,7 @@ MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = "-liconv"; + RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = macosx; }; name = Debug; @@ -337,35 +392,71 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_DEADCODE_DEADSTORES = YES; + CLANG_ANALYZER_DIVIDE_BY_ZERO = YES; + CLANG_ANALYZER_GCD = YES; + CLANG_ANALYZER_GCD_PERFORMANCE = YES; + CLANG_ANALYZER_LIBKERN_RETAIN_COUNT = YES; + CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = YES; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_ANALYZER_MEMORY_MANAGEMENT = YES; + CLANG_ANALYZER_MIG_CONVENTIONS = YES; CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NULL_DEREFERENCE = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_ANALYZER_OBJC_COLLECTIONS = YES; + CLANG_ANALYZER_OBJC_NSCFERROR = YES; + CLANG_ANALYZER_OSOBJECT_C_STYLE_CAST = YES; + CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_GETPW_GETS = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_MKSTEMP = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_UNCHECKEDRETURN = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_VFORK = YES; + CLANG_ANALYZER_SECURITY_KEYCHAIN_API = YES; + CLANG_ANALYZER_USE_AFTER_MOVE = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "c++17"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_STATIC_ANALYZER_MODE = deep; + CLANG_STATIC_ANALYZER_MODE_ON_ANALYZE_ACTION = deep; + CLANG_TIDY_BUGPRONE_ASSERT_SIDE_EFFECT = YES; + CLANG_TIDY_BUGPRONE_INFINITE_LOOP = YES; + CLANG_TIDY_BUGPRONE_MOVE_FORWARDING_REFERENCE = YES; + CLANG_TIDY_BUGPRONE_REDUNDANT_BRANCH_CONDITION = YES; + CLANG_TIDY_MISC_REDUNDANT_EXPRESSION = YES; + CLANG_WARN_ASSIGN_ENUM = YES; + CLANG_WARN_ATOMIC_IMPLICIT_SEQ_CST = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; + CLANG_WARN_COMPLETION_HANDLER_MISUSE = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_CXX0X_EXTENSIONS = YES; + CLANG_WARN_DELETE_NON_VIRTUAL_DTOR = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_FLOAT_CONVERSION = YES; + CLANG_WARN_FRAMEWORK_INCLUDE_PRIVATE_FROM_PUBLIC = YES; CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_PRAGMA_PACK = YES; + CLANG_WARN_PRIVATE_MODULE = YES; CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SEMICOLON_BEFORE_METHOD_BODY = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CLANG_WARN_VEXING_PARSE = YES; + CLANG_WARN__EXIT_TIME_DESTRUCTORS = YES; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; @@ -375,19 +466,38 @@ NDEBUG, "$(inherited)", ); + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; + GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES; + GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = YES; + GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; + GCC_WARN_ABOUT_MISSING_NEWLINE = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + GCC_WARN_ABOUT_POINTER_SIGNEDNESS = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; + GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; + GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; + GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; + GCC_WARN_MISSING_PARENTHESES = YES; + GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; + GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_LABEL = YES; + GCC_WARN_UNUSED_PARAMETER = YES; + GCC_WARN_UNUSED_VALUE = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ../include; MACOSX_DEPLOYMENT_TARGET = 10.15; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; OTHER_LDFLAGS = "-liconv"; + RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = macosx; }; name = Release; diff --git a/UnitTests/hash.cpp b/UnitTests/hash.cpp index b4e45e723..1aae64867 100644 --- a/UnitTests/hash.cpp +++ b/UnitTests/hash.cpp @@ -49,7 +49,7 @@ namespace UnitTests static const char data[] = "This is a test."; h.hash(data, sizeof(data) - sizeof(*data)); h.finalize(); - Assert::AreEqual({0x12,0x0e,0xa8,0xa2,0x5e,0x5d,0x48,0x7b,0xf6,0x8b,0x5f,0x70,0x96,0x44,0x00,0x19}, h); + Assert::AreEqual({{0x12,0x0e,0xa8,0xa2,0x5e,0x5d,0x48,0x7b,0xf6,0x8b,0x5f,0x70,0x96,0x44,0x00,0x19}}, h); } void hash::sha1() @@ -58,6 +58,6 @@ namespace UnitTests static const char data[] = "This is a test."; h.hash(data, sizeof(data) - sizeof(*data)); h.finalize(); - Assert::AreEqual({0xaf,0xa6,0xc8,0xb3,0xa2,0xfa,0xe9,0x57,0x85,0xdc,0x7d,0x96,0x85,0xa5,0x78,0x35,0xd7,0x03,0xac,0x88}, h); + Assert::AreEqual({{0xaf,0xa6,0xc8,0xb3,0xa2,0xfa,0xe9,0x57,0x85,0xdc,0x7d,0x96,0x85,0xa5,0x78,0x35,0xd7,0x03,0xac,0x88}}, h); } } diff --git a/UnitTests/main.cpp b/UnitTests/main.cpp index 09a58ab0b..36ebca5f6 100644 --- a/UnitTests/main.cpp +++ b/UnitTests/main.cpp @@ -6,7 +6,7 @@ #include "pch.hpp" #include -int main(int argc, const char * argv[]) +int main(int, const char *[]) { try { UnitTests::hash::crc32(); diff --git a/UnitTests/parser.cpp b/UnitTests/parser.cpp index af9288803..4d35ab8ef 100644 --- a/UnitTests/parser.cpp +++ b/UnitTests/parser.cpp @@ -22,6 +22,10 @@ namespace Microsoft { } } #endif +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wexit-time-destructors" +#endif namespace UnitTests { @@ -495,3 +499,7 @@ namespace UnitTests // "\r\n"; } } + +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif diff --git a/UnitTests/ring.cpp b/UnitTests/ring.cpp index 35689b19a..a437570c7 100644 --- a/UnitTests/ring.cpp +++ b/UnitTests/ring.cpp @@ -22,7 +22,14 @@ namespace UnitTests { int seed = 0; for (size_t retries = 1000; retries--;) { - for (auto to_write = static_cast(static_cast(::rand()) * ring_capacity / 5 / RAND_MAX); to_write;) { + for (size_t to_write = +#ifdef _WIN32 + static_cast(static_cast(::rand()) * ring_capacity / 5 / RAND_MAX); +#else + ::arc4random_uniform(ring_capacity / 5); +#endif + to_write;) + { int* ptr; size_t num_write; tie(ptr, num_write) = ring.back(); if (to_write < num_write) diff --git a/include/stdex/compat.hpp b/include/stdex/compat.hpp index ac683ab40..f67ff31f1 100644 --- a/include/stdex/compat.hpp +++ b/include/stdex/compat.hpp @@ -181,13 +181,14 @@ #ifdef _WIN32 #define _Unreferenced_(x) UNREFERENCED_PARAMETER(x) #else -#define _Unreferenced_(x) +#define _Unreferenced_(x) (void)(x) #endif #ifndef _WIN32 template size_t _countof(const T (&arr)[N]) { + _Unreferenced_(arr); return std::extent::value; } #endif diff --git a/include/stdex/hash.hpp b/include/stdex/hash.hpp index 30583e902..0b2dbfedf 100644 --- a/include/stdex/hash.hpp +++ b/include/stdex/hash.hpp @@ -27,6 +27,8 @@ namespace stdex class basic_hash { public: + virtual ~basic_hash() {} + /// /// Initializes hash value and internal state /// diff --git a/include/stdex/hex.hpp b/include/stdex/hex.hpp index 3e74ef02f..86ce7454e 100644 --- a/include/stdex/hex.hpp +++ b/include/stdex/hex.hpp @@ -110,15 +110,15 @@ namespace stdex if (i >= size) break; - int x = data[i]; + auto x = data[i]; if ('0' <= x && x <= '9') { - buf = ((buf & 0xf) << 4) | (uint8_t)(x - '0'); + buf = ((buf & 0xf) << 4) | static_cast(x - '0'); num++; } else if ('A' <= x && x <= 'F') { - buf = ((buf & 0xf) << 4) | (uint8_t)(x - ('A' - 10)); + buf = ((buf & 0xf) << 4) | static_cast(x - ('A' - 10)); num++; } else if ('a' <= x && x <= 'f') { - buf = ((buf & 0xf) << 4) | (uint8_t)(x - ('a' - 10)); + buf = ((buf & 0xf) << 4) | static_cast(x - ('a' - 10)); num++; } } diff --git a/include/stdex/html.hpp b/include/stdex/html.hpp index 02eeead5e..bde39139e 100644 --- a/include/stdex/html.hpp +++ b/include/stdex/html.hpp @@ -248,17 +248,17 @@ namespace stdex case '%': { i++; - uint8_t chr; - if ('0' <= src[i] && src[i] <= '9') chr = (src[i++] - '0') << 4; - else if ('A' <= src[i] && src[i] <= 'F') chr = (src[i++] - 'A' + 10) << 4; - else if ('a' <= src[i] && src[i] <= 'f') chr = (src[i++] - 'a' + 10) << 4; + char chr; + if ('0' <= src[i] && src[i] <= '9') chr = static_cast((src[i++] - '0') << 4); + else if ('A' <= src[i] && src[i] <= 'F') chr = static_cast((src[i++] - 'A' + 10) << 4); + else if ('a' <= src[i] && src[i] <= 'f') chr = static_cast((src[i++] - 'a' + 10) << 4); else { dst += '%'; continue; } - if ('0' <= src[i] && src[i] <= '9') chr |= (src[i++] - '0'); - else if ('A' <= src[i] && src[i] <= 'F') chr |= (src[i++] - 'A' + 10); - else if ('a' <= src[i] && src[i] <= 'f') chr |= (src[i++] - 'a' + 10); + if ('0' <= src[i] && src[i] <= '9') chr |= static_cast((src[i++] - '0')); + else if ('A' <= src[i] && src[i] <= 'F') chr |= static_cast((src[i++] - 'A' + 10)); + else if ('a' <= src[i] && src[i] <= 'f') chr |= static_cast((src[i++] - 'a' + 10)); else { dst += '%'; dst += src[i - 1]; continue; } - dst += static_cast(chr); + dst += chr; break; } diff --git a/include/stdex/locale.hpp b/include/stdex/locale.hpp index 054426bdc..0c800060f 100644 --- a/include/stdex/locale.hpp +++ b/include/stdex/locale.hpp @@ -9,6 +9,11 @@ #include #include +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wexit-time-destructors" +#endif + namespace stdex { #ifdef _WIN32 @@ -112,3 +117,7 @@ namespace stdex #endif ); } + +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif diff --git a/include/stdex/parser.hpp b/include/stdex/parser.hpp index d98d59a8e..f8e03ff17 100644 --- a/include/stdex/parser.hpp +++ b/include/stdex/parser.hpp @@ -37,6 +37,7 @@ #elif defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunknown-pragmas" +#pragma GCC diagnostic ignored "-Wunused-parameter" #endif #define ENUM_FLAG_OPERATOR(T,X) \ @@ -377,8 +378,8 @@ namespace stdex wchar_t buf[3]; const wchar_t* chr = next_sgml_cp(text, start, end, this->interval.end, buf); bool r = ((flags & match_case_insensitive) ? - stdex::strnicmp(chr, SIZE_MAX, m_chr.data(), m_chr.size(), m_locale) : - stdex::strncmp(chr, SIZE_MAX, m_chr.data(), m_chr.size())) == 0; + stdex::strnicmp(chr, stdex::strlen(chr), m_chr.data(), m_chr.size(), m_locale) : + stdex::strncmp(chr, stdex::strlen(chr), m_chr.data(), m_chr.size())) == 0; if ((r && !m_invert) || (!r && m_invert)) { this->interval.start = start; return true; diff --git a/include/stdex/progress.hpp b/include/stdex/progress.hpp index af4dd4f6c..6245c0465 100644 --- a/include/stdex/progress.hpp +++ b/include/stdex/progress.hpp @@ -21,6 +21,8 @@ namespace stdex class progress { public: + virtual ~progress() {} + /// /// Set progress indicator text /// diff --git a/include/stdex/sgml.hpp b/include/stdex/sgml.hpp index 6f362a9b4..f7fa65f24 100644 --- a/include/stdex/sgml.hpp +++ b/include/stdex/sgml.hpp @@ -14,6 +14,11 @@ #include #include +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wexit-time-destructors" +#endif + namespace stdex { /// \cond internal @@ -861,3 +866,7 @@ namespace stdex return str2sgml(src.data(), src.size(), what); } } + +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif diff --git a/include/stdex/socket.hpp b/include/stdex/socket.hpp index f56cde7a5..da70cc45a 100644 --- a/include/stdex/socket.hpp +++ b/include/stdex/socket.hpp @@ -25,4 +25,4 @@ namespace stdex constexpr socket_t invalid_socket = ((socket_t)-1); inline int closesocket(_In_ socket_t socket) { return ::close(socket); } #endif -} \ No newline at end of file +} diff --git a/include/stdex/stream.hpp b/include/stdex/stream.hpp index 43e68431f..642e77207 100644 --- a/include/stdex/stream.hpp +++ b/include/stdex/stream.hpp @@ -3027,6 +3027,7 @@ namespace stdex return; throw std::system_error(GetLastError(), std::system_category(), "SetFileTime failed"); #else + _Unreferenced_(date); throw std::runtime_error("not supported"); #endif } @@ -3849,7 +3850,7 @@ namespace stdex return 0; while (to_write) { num_read = stream.read(m_data + dst_offset, to_write); - dst_size = dst_offset += num_read; + /*dst_size =*/ dst_offset += num_read; num_copied += num_read; to_write -= num_read; if (!stream.ok()) { diff --git a/include/stdex/string.hpp b/include/stdex/string.hpp index 548923711..13f8d32a5 100644 --- a/include/stdex/string.hpp +++ b/include/stdex/string.hpp @@ -87,8 +87,8 @@ namespace stdex { _Assume_(chr >= 0x10000); chr -= 0x10000; - str[0] = 0xd800 + static_cast((chr >> 10) & 0x3ff); - str[1] = 0xdc00 + static_cast(chr & 0x3ff); + str[0] = 0xd800 + static_cast((chr >> 10) & 0x3ff); + str[1] = 0xdc00 + static_cast(chr & 0x3ff); } /// diff --git a/include/stdex/sys_info.hpp b/include/stdex/sys_info.hpp index 168d675d6..b2b01fee4 100644 --- a/include/stdex/sys_info.hpp +++ b/include/stdex/sys_info.hpp @@ -16,6 +16,11 @@ #endif #include +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wexit-time-destructors" +#endif + namespace stdex { /// @@ -238,3 +243,7 @@ namespace stdex #endif } sys_info; } + +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif diff --git a/include/stdex/unicode.hpp b/include/stdex/unicode.hpp index 52354c323..0aa121b82 100644 --- a/include/stdex/unicode.hpp +++ b/include/stdex/unicode.hpp @@ -21,6 +21,7 @@ #if defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#pragma GCC diagnostic ignored "-Wexit-time-destructors" #endif namespace stdex