summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-01-11 22:04:52 +0000
committerMatthias Clasen <mclasen@redhat.com>2021-01-11 22:04:52 +0000
commit5044031b53988627c2937c6b5f8919a37e18f21f (patch)
tree8889d29fd674346c993310efde2884ba7392345f
parent9f7119ee58d78c277b0626bf2d093bcf3d082b07 (diff)
parentc514c41d0eab095104f099a6650e4e7c18b35c72 (diff)
downloadgtk+-5044031b53988627c2937c6b5f8919a37e18f21f.tar.gz
Merge branch 'wip/kalev/gcc-11' into 'master'
Avoid diagnostics for gcc-11 false positive out of bounds accesses See merge request GNOME/gtk!3064
-rw-r--r--gtk/gtktextchild.c14
-rw-r--r--gtk/gtktextsegment.c7
2 files changed, 21 insertions, 0 deletions
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..0680b73cfa 100644
--- a/gtk/gtktextsegment.c
+++ b/gtk/gtktextsegment.c
@@ -425,6 +425,12 @@ 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 +446,7 @@ _gtk_toggle_segment_new (GtkTextTagInfo *info, gboolean on)
seg->body.toggle.inNodeCounts = 0;
return seg;
+#pragma GCC diagnostic pop
}
void