Skip to content

Commit 190b030

Browse files
committed
Fix some unreachable code and possible loss of data warnings
1 parent 2f08d5f commit 190b030

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/odbc/Config.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@
2323
# endif
2424
#endif
2525
//------------------------------------------------------------------------------
26-
#ifdef _WIN32
26+
#if defined(__clang__) || defined(__GNUC__)
27+
# define ODBC_UNREACHABLE __builtin_unreachable()
28+
#elif defined(_MSC_VER)
29+
# define ODBC_UNREACHABLE __assume(false)
30+
#else
31+
# define ODBC_UNREACHABLE ((void)0)
32+
#endif
33+
//------------------------------------------------------------------------------
34+
#ifdef _MSC_VER
2735
# pragma warning(disable: 4251 4275)
2836
#endif
2937
//------------------------------------------------------------------------------

src/odbc/StringConverter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ u16string StringConverter::utf8ToUtf16(const char* begin, const char* end)
5353
}
5454
else
5555
{
56-
str.push_back(cp.second);
56+
str.push_back(static_cast<char16_t>(cp.second));
5757
}
5858
}
5959

src/odbc/internal/charset/Utf8.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ inline bool isValidSequence(int len, const char* c)
5252
return ((c[0] & 0xF8) == 0xF0) && ((c[1] & 0xC0) == 0x80)
5353
&& ((c[2] & 0xC0) == 0x80) && ((c[3] & 0xC0) == 0x80);
5454
}
55-
assert(false);
55+
ODBC_UNREACHABLE;
5656
}
5757
//------------------------------------------------------------------------------
5858
/**
@@ -121,7 +121,7 @@ inline char32_t decode(int len, const char* c)
121121
case 4:
122122
return decode4(c);
123123
}
124-
assert(false);
124+
ODBC_UNREACHABLE;
125125
}
126126
//------------------------------------------------------------------------------
127127
} // namespace utf8

0 commit comments

Comments
 (0)