Skip to content

Commit 456af35

Browse files
authored
build : suppress gcc15 compile warnings (#14261)
* Change _contains_any() substrs to std::string_view and fix the find comparison logic.
1 parent 600e3e9 commit 456af35

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

common/common.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,11 +706,17 @@ bool fs_validate_filename(const std::string & filename) {
706706
// disable C++17 deprecation warning for std::codecvt_utf8
707707
# pragma clang diagnostic push
708708
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
709+
#elif defined(__GNUC__)
710+
# pragma GCC diagnostic push
711+
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
709712
#endif
713+
710714
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> converter;
711715

712716
#if defined(__clang__)
713717
# pragma clang diagnostic pop
718+
#elif defined(__GNUC__)
719+
# pragma GCC diagnostic pop
714720
#endif
715721

716722
filename_utf32 = converter.from_bytes(filename);

ggml/src/ggml-backend-reg.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@
6969
#if defined(__clang__)
7070
# pragma clang diagnostic push
7171
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
72+
#elif defined(__GNUC__)
73+
# pragma GCC diagnostic push
74+
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
7275
#endif
7376

7477
namespace fs = std::filesystem;
@@ -91,6 +94,8 @@ static std::string path_str(const fs::path & path) {
9194

9295
#if defined(__clang__)
9396
# pragma clang diagnostic pop
97+
#elif defined(__GNUC__)
98+
# pragma GCC diagnostic pop
9499
#endif
95100

96101
#ifdef _WIN32

src/llama-vocab.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,9 +2060,9 @@ void llama_vocab::impl::load(llama_model_loader & ml, const LLM_KV & kv) {
20602060
//NOTE: Per token attributes are missing from the GGUF file.
20612061
//TODO: Extract attributes from GGUF file.
20622062
{
2063-
auto _contains_any = [] (const std::string & str, const std::vector<std::string> & substrs) -> bool {
2063+
auto _contains_any = [] (const std::string & str, const std::vector<std::string_view> & substrs) -> bool {
20642064
for (const auto & substr : substrs) {
2065-
if (str.find(substr) < std::string::npos) {
2065+
if (str.find(substr) != std::string::npos) {
20662066
return true;
20672067
}
20682068
}

src/unicode.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,17 @@ static inline std::wstring unicode_wstring_from_utf8(const std::string & s) {
204204
// disable C++17 deprecation warning for std::codecvt_utf8
205205
# pragma clang diagnostic push
206206
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
207+
#elif defined(__GNUC__)
208+
# pragma GCC diagnostic push
209+
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
207210
#endif
208211

209212
std::wstring_convert<std::codecvt_utf8<wchar_t>> conv;
210213

211214
#if defined(__clang__)
212215
# pragma clang diagnostic pop
216+
#elif defined(__GNUC__)
217+
# pragma GCC diagnostic pop
213218
#endif
214219

215220
return conv.from_bytes(s);

0 commit comments

Comments
 (0)