diff --git a/src/String/StringView.hpp b/src/String/StringView.hpp index 05f8f10..c5d6b3a 100644 --- a/src/String/StringView.hpp +++ b/src/String/StringView.hpp @@ -22,10 +22,16 @@ namespace ArbUt { public: __ConstStringCharHolder(const char* non_null value, size_t length) : _value(new char[length + 1]) { EnsureNotNull(value); -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstringop-truncation" + // For GCC we need to disable a diagnostic that does not like this. +#if defined(__GNUC__) && !defined(__clang__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstringop-truncation" +#endif strncpy(_value, value, length); -#pragma GCC diagnostic pop +#if defined(__GNUC__) && !defined(__clang__) + #pragma GCC diagnostic pop +#endif + _value[length] = 0; } ~__ConstStringCharHolder() noexcept { delete[] _value; }