[gtk/wip/kalev/gcc-11] Avoid diagnostics for gcc-11 false positive out of bounds accesses
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/kalev/gcc-11] Avoid diagnostics for gcc-11 false positive out of bounds accesses
- Date: Sun, 10 Jan 2021 08:40:24 +0000 (UTC)
commit 71965b8392d34ecc8ef2ae0a1dd3be372d1e167f
Author: Kalev Lember <klember redhat com>
Date: Sun Jan 10 09:35:40 2021 +0100
Avoid diagnostics for gcc-11 false positive out of bounds accesses
This is a patch by Jeff Law <law redhat com> done in downstream Fedora
to fix the build with gcc 11.
gtk/gtktextchild.c | 14 ++++++++++++++
gtk/gtktextsegment.c | 8 ++++++++
2 files changed, 22 insertions(+)
---
diff --git a/gtk/gtktextchild.c b/gtk/gtktextchild.c
index 4d5e30e44f..915b9917dd 100644
--- a/gtk/gtktextchild.c
+++ b/gtk/gtktextchild.c
@@ -169,6 +169,12 @@ const GtkTextLineSegmentClass gtk_text_paintable_type = {
GtkTextLineSegment *
_gtk_paintable_segment_new (GdkPaintable *paintable)
{
+ /* gcc-11 issues a diagnostic here because the size allocated
+ for SEG does not cover the entire size of a GtkTextLineSegment
+ and gcc has no way to know that the union will only be used
+ for limited types and the additional space is not needed. */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
GtkTextLineSegment *seg;
guint flags;
@@ -204,6 +210,7 @@ _gtk_paintable_segment_new (GdkPaintable *paintable)
g_object_ref (paintable);
return seg;
+#pragma GCC diagnostic pop
}
@@ -280,6 +287,12 @@ const GtkTextLineSegmentClass gtk_text_child_type = {
GtkTextLineSegment *
_gtk_widget_segment_new (GtkTextChildAnchor *anchor)
{
+ /* gcc-11 issues a diagnostic here because the size allocated
+ for SEG does not cover the entire size of a GtkTextLineSegment
+ and gcc has no way to know that the union will only be used
+ for limited types and the additional space is not needed. */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
GtkTextLineSegment *seg;
seg = g_slice_alloc (WIDGET_SEG_SIZE);
@@ -303,6 +316,7 @@ _gtk_widget_segment_new (GtkTextChildAnchor *anchor)
g_object_ref (anchor);
return seg;
+#pragma GCC diagnostic pop
}
void
diff --git a/gtk/gtktextsegment.c b/gtk/gtktextsegment.c
index a202ab603c..aaac2918ba 100644
--- a/gtk/gtktextsegment.c
+++ b/gtk/gtktextsegment.c
@@ -425,6 +425,13 @@ char_segment_check_func (GtkTextLineSegment *segPtr, GtkTextLine *line)
GtkTextLineSegment*
_gtk_toggle_segment_new (GtkTextTagInfo *info, gboolean on)
{
+ /* gcc-11 issues a diagnostic here because the size allocated
+ for SEG does not cover the entire size of a GtkTextLineSegment
+ and gcc has no way to know that the union will only be used
+ for limited types and the additional space is not needed. */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
+
GtkTextLineSegment *seg;
seg = g_slice_alloc (TSEG_SIZE);
@@ -440,6 +447,7 @@ _gtk_toggle_segment_new (GtkTextTagInfo *info, gboolean on)
seg->body.toggle.inNodeCounts = 0;
return seg;
+#pragma GCC diagnostic pop
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]