1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-11 13:10:58 +00:00

Core: Sidestep GCC false-positive warnings

(cherry picked from commits acdb8667b5
and 6733345f73)

Adds some more fixes for 4.5.

Co-authored-by: Lukas Tenbrink <lukas.tenbrink@gmail.com>
Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
This commit is contained in:
Thaddeus Crews
2025-10-17 15:21:57 -05:00
committed by Rémi Verschelde
parent 8351a28101
commit 20c59d6924
6 changed files with 30 additions and 0 deletions

View File

@@ -5855,6 +5855,15 @@ String String::unquote() const {
return substr(1, length() - 2);
}
// MinGW-GCC false positives because CharStringT::length() is int (so possibly < 0).
// Don't silence for regular GCC/Clang as this is code that _could_ exhibit actual overflow bugs.
#ifdef __MINGW32__
GODOT_GCC_WARNING_PUSH
GODOT_GCC_PRAGMA(GCC diagnostic warning "-Wstringop-overflow=0")
GODOT_GCC_WARNING_IGNORE("-Warray-bounds")
GODOT_GCC_WARNING_IGNORE("-Wrestrict")
#endif
Vector<uint8_t> String::to_ascii_buffer() const {
const String *s = this;
if (s->is_empty()) {
@@ -5903,6 +5912,10 @@ Vector<uint8_t> String::to_utf16_buffer() const {
return retval;
}
#ifdef __MINGW32__
GODOT_GCC_WARNING_POP
#endif
Vector<uint8_t> String::to_utf32_buffer() const {
const String *s = this;
if (s->is_empty()) {