temp/gtk+3.0: fix build (MR 3154)

Fix the build failure when built with newer gcc:

../gtk/gtktextsegment.c: In function '_gtk_toggle_segment_new':
../gtk/gtktextsegment.c:433:6: error: array subscript 'GtkTextLineSegment {aka struct _GtkTextLineSegment}[0]' is partly outside array bounds of 'unsigned char[40]' [-Werror=array-bounds]
  433 |   seg->type = on ? &gtk_text_toggle_on_type : &gtk_text_toggle_off_type;
      |      ^~

Patch source: b4e110920a
This commit is contained in:
Luca Weiss 2022-05-24 22:43:18 +02:00 committed by Bart Ribbers
parent d23fd662f2
commit f8b96744fa
No known key found for this signature in database
GPG key ID: 0BF4C1B5988C50D8
2 changed files with 94 additions and 1 deletions

View file

@ -0,0 +1,91 @@
From b4e110920aa18e6cc149ccbbfcd90b5143526e6d Mon Sep 17 00:00:00 2001
From: Matthias Clasen <mclasen@redhat.com>
Date: Mon, 11 Jan 2021 22:04:52 +0000
Subject: [PATCH] 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
(cherry picked from commit 5044031b53988627c2937c6b5f8919a37e18f21f)
c514c41d Avoid diagnostics for gcc-11 false positive out of bounds accesses
---
gtk/gtktextchild.c | 14 ++++++++++++++
gtk/gtktextsegment.c | 7 +++++++
2 files changed, 21 insertions(+)
diff --git a/gtk/gtktextchild.c b/gtk/gtktextchild.c
index 2ff7de2394..cbbcf91d66 100644
--- a/gtk/gtktextchild.c
+++ b/gtk/gtktextchild.c
@@ -129,6 +129,12 @@ const GtkTextLineSegmentClass gtk_text_pixbuf_type = {
GtkTextLineSegment *
_gtk_pixbuf_segment_new (GdkPixbuf *pixbuf)
{
+ /* 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 (PIXBUF_SEG_SIZE);
@@ -148,6 +154,7 @@ _gtk_pixbuf_segment_new (GdkPixbuf *pixbuf)
g_object_ref (pixbuf);
return seg;
+#pragma GCC diagnostic pop
}
@@ -224,6 +231,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);
@@ -247,6 +260,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 8539db5297..8e00b1ddc9 100644
--- a/gtk/gtktextsegment.c
+++ b/gtk/gtktextsegment.c
@@ -426,6 +426,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);
@@ -441,6 +447,7 @@ _gtk_toggle_segment_new (GtkTextTagInfo *info, gboolean on)
seg->body.toggle.inNodeCounts = 0;
return seg;
+#pragma GCC diagnostic pop
}
void
--
2.36.1

View file

@ -1,7 +1,7 @@
# Forked from Alpine to apply Purism's patches for responsivness # Forked from Alpine to apply Purism's patches for responsivness
pkgname=gtk+3.0 pkgname=gtk+3.0
pkgver=9999_git20210602 pkgver=9999_git20210602
pkgrel=0 pkgrel=1
# pureos/byzantium branch # pureos/byzantium branch
_commit="f05e4021ed82bfbabf566398d0511b6745a5745e" _commit="f05e4021ed82bfbabf566398d0511b6745a5745e"
pkgdesc="The GTK+ Toolkit (v3)" pkgdesc="The GTK+ Toolkit (v3)"
@ -60,6 +60,7 @@ checkdepends="
gdk-pixbuf gdk-pixbuf
" "
source="https://source.puri.sm/Librem5/gtk/-/archive/$_commit/gtk-$_commit.tar.gz source="https://source.puri.sm/Librem5/gtk/-/archive/$_commit/gtk-$_commit.tar.gz
0001-Avoid-diagnostics-for-gcc-11-false-positive-out-of-b.patch
" "
builddir="$srcdir/gtk-$_commit" builddir="$srcdir/gtk-$_commit"
@ -138,4 +139,5 @@ doc() {
sha512sums=" sha512sums="
942d2e24bdb4e9fea7fc5bbd3d41ab203b69f6352566f43164e59842d49163e37d638858032cf2322b9b4c279c8c9a07a63d58fa7ec8554f3194c17ae3185fd7 gtk-f05e4021ed82bfbabf566398d0511b6745a5745e.tar.gz 942d2e24bdb4e9fea7fc5bbd3d41ab203b69f6352566f43164e59842d49163e37d638858032cf2322b9b4c279c8c9a07a63d58fa7ec8554f3194c17ae3185fd7 gtk-f05e4021ed82bfbabf566398d0511b6745a5745e.tar.gz
346514bb7c1853afcbeff4a5a25a2b9800e135e44271e48cdf400dc607dadd41af57d89ee4f4e24aedc358292d9c45db931dbbd84dae6a10886d8ae633ca8434 0001-Avoid-diagnostics-for-gcc-11-false-positive-out-of-b.patch
" "