From 8dbceaa398d92c9c7492ffeb483f2bd6fab30c17 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 28 Feb 2023 10:50:35 -0800 Subject: [PATCH] QRegion: upgrade Q_ASSUME to Q_ASSERT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is to fix the warning qregion.cpp:3582:12: error: ‘ET.EdgeTable::ymax’ may be used uninitialized [-Werror=maybe-uninitialized] Because the previous code in PolygonRegion() was: Q_ASSUME(Count > 1); But Q_ASSUME is becoming a no-op with GCC 12, so when this disappears, compiler rightly considered Count < 2 as a valid input. Therefore, when CreateETandAET() was called and had if (count < 2) return; The compiler again rightly concluded that it was a valid condition (after all, you're checking it!), leading to ET.ymax being used uninitialized. Since that Q_ASSUME really meant the condition of Count < 2 was not permitted, we may as well upgrade to Q_ASSERT in both places. Change-Id: I7f354474adce419ca6c2fffd1748119ef0092fa4 Reviewed-by: Marc Mutz --- src/gui/painting/qregion.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index 457c2cc259..94f1f31e6a 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -3191,8 +3191,7 @@ static void CreateETandAET(int count, const QPoint *pts, int iSLLBlock = 0; int dy; - if (count < 2) - return; + Q_ASSERT(count > 1); /* * initialize the Active Edge Table @@ -3538,7 +3537,7 @@ static QRegionPrivate *PolygonRegion(const QPoint *Pts, int Count, int rule) POINTBLOCK *tmpPtBlock; int numFullPtBlocks = 0; - Q_ASSUME(Count > 1); + Q_ASSERT(Count > 1); region = new QRegionPrivate;