summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-05-05 14:18:02 +0200
committerStephan Bergmann <sbergman@redhat.com>2020-05-05 21:43:12 +0200
commit0613619a61c39eff4b7d47d7afdd991658986a72 (patch)
tree74647092741f17550f266571b11dc81a44f84451
parentb7a53077fd592c514d2f255cc19e4f0deb483dca (diff)
Disable -Wstringop-overflow in --enable-optimized builds with GCC
This reverts commit e287fde52fb9de5bdf1d00c8a3fbfcca7db9892c "Silence bogus -Wstringop-overflow with GCC trunk towards GCC 10", as that workaround, which happened to work for some revisions of GCC trunk towards GCC 10, no longer works for GCC 10 release candidates, see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92893#c9> "[10 Regression] Unhelpful -Wstringop-overflow warning for a trailing one-element array". (Using -Wstringop-overflow=1 instead of the -Wstringop-overflow=2 default would have still caused bogus warnings, requiring -Wno-stringop-overflow.) Change-Id: I9b7342748c18da32f509b4a0e0653aede8447657 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93499 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r--include/rtl/strbuf.hxx8
-rw-r--r--include/rtl/string.hxx16
-rw-r--r--include/rtl/ustring.hxx16
-rw-r--r--solenv/gbuild/platform/com_GCC_defs.mk3
4 files changed, 3 insertions, 40 deletions
diff --git a/include/rtl/strbuf.hxx b/include/rtl/strbuf.hxx
index e9a548297016..2a303ce998e6 100644
--- a/include/rtl/strbuf.hxx
+++ b/include/rtl/strbuf.hxx
@@ -569,15 +569,7 @@ public:
return *this;
l += pData->length;
rtl_stringbuffer_ensureCapacity( &pData, &nCapacity, l );
-#if defined __GNUC__ && __GNUC__ == 10 && !defined __clang__
- // Avoid some bogus GCC 10 trunk -Werror=stringop-overflow (see
- // <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92893> "Unhelpful -Wstringop-overflow
- // warning"):
- struct Hack { char c; char a[]; };
- char* end = c.addData( &reinterpret_cast<Hack *>(pData->buffer)->c + pData->length );
-#else
char* end = c.addData( pData->buffer + pData->length );
-#endif
*end = '\0';
pData->length = l;
return *this;
diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx
index 4f600affdabe..809b0a11bcd5 100644
--- a/include/rtl/string.hxx
+++ b/include/rtl/string.hxx
@@ -273,15 +273,7 @@ public:
pData = rtl_string_alloc( l );
if (l != 0)
{
-#if defined __GNUC__ && __GNUC__ == 10 && !defined __clang__
- // Avoid some bogus GCC 10 trunk -Werror=stringop-overflow (see
- // <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92893> "Unhelpful -Wstringop-overflow
- // warning"):
- struct Hack { char c; char a[]; };
- char* end = c.addData( &reinterpret_cast<Hack *>(pData->buffer)->c );
-#else
char* end = c.addData( pData->buffer );
-#endif
pData->length = l;
*end = '\0';
}
@@ -389,15 +381,7 @@ public:
return *this;
l += pData->length;
rtl_string_ensureCapacity( &pData, l );
-#if defined __GNUC__ && __GNUC__ == 10 && !defined __clang__
- // Avoid some bogus GCC 10 trunk -Werror=stringop-overflow (see
- // <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92893> "Unhelpful -Wstringop-overflow
- // warning"):
- struct Hack { char c; char a[]; };
- char* end = c.addData( &reinterpret_cast<Hack *>(pData->buffer)->c + pData->length );
-#else
char* end = c.addData( pData->buffer + pData->length );
-#endif
*end = '\0';
pData->length = l;
return *this;
diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx
index ffe42d139215..5f0c1032c603 100644
--- a/include/rtl/ustring.hxx
+++ b/include/rtl/ustring.hxx
@@ -401,15 +401,7 @@ public:
pData = rtl_uString_alloc( l );
if (l != 0)
{
-#if defined __GNUC__ && __GNUC__ == 10 && !defined __clang__
- // Avoid some bogus GCC 10 trunk -Werror=stringop-overflow (see
- // <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92893> "Unhelpful -Wstringop-overflow
- // warning"):
- struct Hack { sal_Unicode c; sal_Unicode a[]; };
- sal_Unicode* end = c.addData( reinterpret_cast<Hack *>(pData->buffer - 1)->a );
-#else
sal_Unicode* end = c.addData( pData->buffer );
-#endif
pData->length = l;
*end = '\0';
// TODO realloc in case pData->length is noticeably smaller than l?
@@ -638,15 +630,7 @@ public:
return *this;
l += pData->length;
rtl_uString_ensureCapacity( &pData, l );
-#if defined __GNUC__ && __GNUC__ == 10 && !defined __clang__
- // Avoid some bogus GCC 10 trunk -Werror=stringop-overflow (see
- // <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92893> "Unhelpful -Wstringop-overflow
- // warning"):
- struct Hack { sal_Unicode c; sal_Unicode a[]; };
- sal_Unicode* end = c.addData( reinterpret_cast<Hack *>(pData->buffer - 1)->a + pData->length );
-#else
sal_Unicode* end = c.addData( pData->buffer + pData->length );
-#endif
*end = '\0';
pData->length = l;
return *this;
diff --git a/solenv/gbuild/platform/com_GCC_defs.mk b/solenv/gbuild/platform/com_GCC_defs.mk
index baeb215bfb9e..4d3602864bc8 100644
--- a/solenv/gbuild/platform/com_GCC_defs.mk
+++ b/solenv/gbuild/platform/com_GCC_defs.mk
@@ -162,6 +162,9 @@ endif
endif
gb_CFLAGS_WERROR = $(if $(ENABLE_WERROR),-Werror)
+ifeq ($(ENABLE_OPTIMIZED)-$(COM_IS_CLANG),TRUE-)
+gb_CFLAGS_WERROR += -Wno-stringop-overflow
+endif
# This is the default in non-C++11 mode
ifeq ($(COM_IS_CLANG),TRUE)