Xcode: turn on and resolve all warnings

This commit is contained in:
Simon Rozman 2024-02-14 15:05:41 +01:00
parent 0560c7bce9
commit 0a719e3081
18 changed files with 197 additions and 37 deletions

View File

@ -275,35 +275,71 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; 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_NONNULL = YES;
CLANG_ANALYZER_NULL_DEREFERENCE = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 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_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = 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_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES; CLANG_WARN_COMMA = YES;
CLANG_WARN_COMPLETION_HANDLER_MISUSE = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_CXX0X_EXTENSIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DELETE_NON_VIRTUAL_DTOR = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = 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_IMPLICIT_SIGN_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_PRAGMA_PACK = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_PRIVATE_MODULE = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_SEMICOLON_BEFORE_METHOD_BODY = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES; 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; COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
@ -315,13 +351,31 @@
_DEBUG, _DEBUG,
"$(inherited)", "$(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_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_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_SIGN_COMPARE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNKNOWN_PRAGMAS = YES;
GCC_WARN_UNUSED_FUNCTION = 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; GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = ../include; HEADER_SEARCH_PATHS = ../include;
MACOSX_DEPLOYMENT_TARGET = 10.15; MACOSX_DEPLOYMENT_TARGET = 10.15;
@ -329,6 +383,7 @@
MTL_FAST_MATH = YES; MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-liconv"; OTHER_LDFLAGS = "-liconv";
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = macosx; SDKROOT = macosx;
}; };
name = Debug; name = Debug;
@ -337,35 +392,71 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; 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_NONNULL = YES;
CLANG_ANALYZER_NULL_DEREFERENCE = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 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_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = 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_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES; CLANG_WARN_COMMA = YES;
CLANG_WARN_COMPLETION_HANDLER_MISUSE = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_CXX0X_EXTENSIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DELETE_NON_VIRTUAL_DTOR = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = 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_IMPLICIT_SIGN_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_PRAGMA_PACK = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_PRIVATE_MODULE = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_SEMICOLON_BEFORE_METHOD_BODY = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES; 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; COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO; ENABLE_NS_ASSERTIONS = NO;
@ -375,19 +466,38 @@
NDEBUG, NDEBUG,
"$(inherited)", "$(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_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_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_SIGN_COMPARE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNKNOWN_PRAGMAS = YES; GCC_WARN_UNKNOWN_PRAGMAS = YES;
GCC_WARN_UNUSED_FUNCTION = 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; GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = ../include; HEADER_SEARCH_PATHS = ../include;
MACOSX_DEPLOYMENT_TARGET = 10.15; MACOSX_DEPLOYMENT_TARGET = 10.15;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES; MTL_FAST_MATH = YES;
OTHER_LDFLAGS = "-liconv"; OTHER_LDFLAGS = "-liconv";
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = macosx; SDKROOT = macosx;
}; };
name = Release; name = Release;

View File

@ -49,7 +49,7 @@ namespace UnitTests
static const char data[] = "This is a test."; static const char data[] = "This is a test.";
h.hash(data, sizeof(data) - sizeof(*data)); h.hash(data, sizeof(data) - sizeof(*data));
h.finalize(); h.finalize();
Assert::AreEqual<stdex::md5_t>({0x12,0x0e,0xa8,0xa2,0x5e,0x5d,0x48,0x7b,0xf6,0x8b,0x5f,0x70,0x96,0x44,0x00,0x19}, h); Assert::AreEqual<stdex::md5_t>({{0x12,0x0e,0xa8,0xa2,0x5e,0x5d,0x48,0x7b,0xf6,0x8b,0x5f,0x70,0x96,0x44,0x00,0x19}}, h);
} }
void hash::sha1() void hash::sha1()
@ -58,6 +58,6 @@ namespace UnitTests
static const char data[] = "This is a test."; static const char data[] = "This is a test.";
h.hash(data, sizeof(data) - sizeof(*data)); h.hash(data, sizeof(data) - sizeof(*data));
h.finalize(); h.finalize();
Assert::AreEqual<stdex::sha1_t>({0xaf,0xa6,0xc8,0xb3,0xa2,0xfa,0xe9,0x57,0x85,0xdc,0x7d,0x96,0x85,0xa5,0x78,0x35,0xd7,0x03,0xac,0x88}, h); Assert::AreEqual<stdex::sha1_t>({{0xaf,0xa6,0xc8,0xb3,0xa2,0xfa,0xe9,0x57,0x85,0xdc,0x7d,0x96,0x85,0xa5,0x78,0x35,0xd7,0x03,0xac,0x88}}, h);
} }
} }

View File

@ -6,7 +6,7 @@
#include "pch.hpp" #include "pch.hpp"
#include <iostream> #include <iostream>
int main(int argc, const char * argv[]) int main(int, const char *[])
{ {
try { try {
UnitTests::hash::crc32(); UnitTests::hash::crc32();

View File

@ -22,6 +22,10 @@ namespace Microsoft {
} }
} }
#endif #endif
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wexit-time-destructors"
#endif
namespace UnitTests namespace UnitTests
{ {
@ -495,3 +499,7 @@ namespace UnitTests
// "\r\n"; // "\r\n";
} }
} }
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif

View File

@ -22,7 +22,14 @@ namespace UnitTests
{ {
int seed = 0; int seed = 0;
for (size_t retries = 1000; retries--;) { for (size_t retries = 1000; retries--;) {
for (auto to_write = static_cast<size_t>(static_cast<uint64_t>(::rand()) * ring_capacity / 5 / RAND_MAX); to_write;) { for (size_t to_write =
#ifdef _WIN32
static_cast<size_t>(static_cast<uint64_t>(::rand()) * ring_capacity / 5 / RAND_MAX);
#else
::arc4random_uniform(ring_capacity / 5);
#endif
to_write;)
{
int* ptr; size_t num_write; int* ptr; size_t num_write;
tie(ptr, num_write) = ring.back(); tie(ptr, num_write) = ring.back();
if (to_write < num_write) if (to_write < num_write)

View File

@ -181,13 +181,14 @@
#ifdef _WIN32 #ifdef _WIN32
#define _Unreferenced_(x) UNREFERENCED_PARAMETER(x) #define _Unreferenced_(x) UNREFERENCED_PARAMETER(x)
#else #else
#define _Unreferenced_(x) #define _Unreferenced_(x) (void)(x)
#endif #endif
#ifndef _WIN32 #ifndef _WIN32
template <class T, size_t N> template <class T, size_t N>
size_t _countof(const T (&arr)[N]) size_t _countof(const T (&arr)[N])
{ {
_Unreferenced_(arr);
return std::extent<T[N]>::value; return std::extent<T[N]>::value;
} }
#endif #endif

View File

@ -27,6 +27,8 @@ namespace stdex
class basic_hash class basic_hash
{ {
public: public:
virtual ~basic_hash() {}
/// ///
/// Initializes hash value and internal state /// Initializes hash value and internal state
/// ///

View File

@ -110,15 +110,15 @@ namespace stdex
if (i >= size) if (i >= size)
break; break;
int x = data[i]; auto x = data[i];
if ('0' <= x && x <= '9') { if ('0' <= x && x <= '9') {
buf = ((buf & 0xf) << 4) | (uint8_t)(x - '0'); buf = ((buf & 0xf) << 4) | static_cast<uint8_t>(x - '0');
num++; num++;
} else if ('A' <= x && x <= 'F') { } else if ('A' <= x && x <= 'F') {
buf = ((buf & 0xf) << 4) | (uint8_t)(x - ('A' - 10)); buf = ((buf & 0xf) << 4) | static_cast<uint8_t>(x - ('A' - 10));
num++; num++;
} else if ('a' <= x && x <= 'f') { } else if ('a' <= x && x <= 'f') {
buf = ((buf & 0xf) << 4) | (uint8_t)(x - ('a' - 10)); buf = ((buf & 0xf) << 4) | static_cast<uint8_t>(x - ('a' - 10));
num++; num++;
} }
} }

View File

@ -248,17 +248,17 @@ namespace stdex
case '%': { case '%': {
i++; i++;
uint8_t chr; char chr;
if ('0' <= src[i] && src[i] <= '9') chr = (src[i++] - '0') << 4; if ('0' <= src[i] && src[i] <= '9') chr = static_cast<char>((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 = static_cast<char>((src[i++] - 'A' + 10) << 4);
else if ('a' <= src[i] && src[i] <= 'f') chr = (src[i++] - 'a' + 10) << 4; else if ('a' <= src[i] && src[i] <= 'f') chr = static_cast<char>((src[i++] - 'a' + 10) << 4);
else { dst += '%'; continue; } else { dst += '%'; continue; }
if ('0' <= src[i] && src[i] <= '9') chr |= (src[i++] - '0'); if ('0' <= src[i] && src[i] <= '9') chr |= static_cast<char>((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 |= static_cast<char>((src[i++] - 'A' + 10));
else if ('a' <= src[i] && src[i] <= 'f') chr |= (src[i++] - 'a' + 10); else if ('a' <= src[i] && src[i] <= 'f') chr |= static_cast<char>((src[i++] - 'a' + 10));
else { dst += '%'; dst += src[i - 1]; continue; } else { dst += '%'; dst += src[i - 1]; continue; }
dst += static_cast<char>(chr); dst += chr;
break; break;
} }

View File

@ -9,6 +9,11 @@
#include <locale.h> #include <locale.h>
#include <memory> #include <memory>
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wexit-time-destructors"
#endif
namespace stdex namespace stdex
{ {
#ifdef _WIN32 #ifdef _WIN32
@ -112,3 +117,7 @@ namespace stdex
#endif #endif
); );
} }
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif

View File

@ -37,6 +37,7 @@
#elif defined(__GNUC__) #elif defined(__GNUC__)
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunknown-pragmas" #pragma GCC diagnostic ignored "-Wunknown-pragmas"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif #endif
#define ENUM_FLAG_OPERATOR(T,X) \ #define ENUM_FLAG_OPERATOR(T,X) \
@ -377,8 +378,8 @@ namespace stdex
wchar_t buf[3]; wchar_t buf[3];
const wchar_t* chr = next_sgml_cp(text, start, end, this->interval.end, buf); const wchar_t* chr = next_sgml_cp(text, start, end, this->interval.end, buf);
bool r = ((flags & match_case_insensitive) ? bool r = ((flags & match_case_insensitive) ?
stdex::strnicmp(chr, SIZE_MAX, m_chr.data(), m_chr.size(), m_locale) : stdex::strnicmp(chr, stdex::strlen(chr), m_chr.data(), m_chr.size(), m_locale) :
stdex::strncmp(chr, SIZE_MAX, m_chr.data(), m_chr.size())) == 0; stdex::strncmp(chr, stdex::strlen(chr), m_chr.data(), m_chr.size())) == 0;
if ((r && !m_invert) || (!r && m_invert)) { if ((r && !m_invert) || (!r && m_invert)) {
this->interval.start = start; this->interval.start = start;
return true; return true;

View File

@ -21,6 +21,8 @@ namespace stdex
class progress class progress
{ {
public: public:
virtual ~progress() {}
/// ///
/// Set progress indicator text /// Set progress indicator text
/// ///

View File

@ -14,6 +14,11 @@
#include <string_view> #include <string_view>
#include <string> #include <string>
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wexit-time-destructors"
#endif
namespace stdex namespace stdex
{ {
/// \cond internal /// \cond internal
@ -861,3 +866,7 @@ namespace stdex
return str2sgml(src.data(), src.size(), what); return str2sgml(src.data(), src.size(), what);
} }
} }
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif

View File

@ -25,4 +25,4 @@ namespace stdex
constexpr socket_t invalid_socket = ((socket_t)-1); constexpr socket_t invalid_socket = ((socket_t)-1);
inline int closesocket(_In_ socket_t socket) { return ::close(socket); } inline int closesocket(_In_ socket_t socket) { return ::close(socket); }
#endif #endif
} }

View File

@ -3027,6 +3027,7 @@ namespace stdex
return; return;
throw std::system_error(GetLastError(), std::system_category(), "SetFileTime failed"); throw std::system_error(GetLastError(), std::system_category(), "SetFileTime failed");
#else #else
_Unreferenced_(date);
throw std::runtime_error("not supported"); throw std::runtime_error("not supported");
#endif #endif
} }
@ -3849,7 +3850,7 @@ namespace stdex
return 0; return 0;
while (to_write) { while (to_write) {
num_read = stream.read(m_data + dst_offset, 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; num_copied += num_read;
to_write -= num_read; to_write -= num_read;
if (!stream.ok()) { if (!stream.ok()) {

View File

@ -87,8 +87,8 @@ namespace stdex
{ {
_Assume_(chr >= 0x10000); _Assume_(chr >= 0x10000);
chr -= 0x10000; chr -= 0x10000;
str[0] = 0xd800 + static_cast<utf32_t>((chr >> 10) & 0x3ff); str[0] = 0xd800 + static_cast<utf16_t>((chr >> 10) & 0x3ff);
str[1] = 0xdc00 + static_cast<utf32_t>(chr & 0x3ff); str[1] = 0xdc00 + static_cast<utf16_t>(chr & 0x3ff);
} }
/// ///

View File

@ -16,6 +16,11 @@
#endif #endif
#include <memory> #include <memory>
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wexit-time-destructors"
#endif
namespace stdex namespace stdex
{ {
/// ///
@ -238,3 +243,7 @@ namespace stdex
#endif #endif
} sys_info; } sys_info;
} }
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif

View File

@ -21,6 +21,7 @@
#if defined(__GNUC__) #if defined(__GNUC__)
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#pragma GCC diagnostic ignored "-Wexit-time-destructors"
#endif #endif
namespace stdex namespace stdex