From 70575264bd1d3caef6c3c6e7b19cffa6d94f804b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 31 May 2022 21:10:06 +0200 Subject: [PATCH] QRasterPaintEngine: fix GCC 12 -Werror=array-bounds An enum variable can legally have values larger than the largest enumerator, so GCC isn't wrong in warning about accesses out of bounds. But we know that we don't OR enumerators of this enum together, so tell GCC, too, by using a Q_ASSUME(). Pick-to: 6.3 6.2 Task-number: QTBUG-103923 Change-Id: I3472fdb19a73a22f04df53a13f809d899613adf5 Reviewed-by: Thiago Macieira --- src/gui/painting/qpaintengine_raster.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 4192a0fa07..52ee689188 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -2277,6 +2277,7 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe || d->rasterBuffer->compositionMode == QPainter::CompositionMode_Source)) { RotationType rotationType = qRotationType(s->matrix); + Q_ASSUME(d->rasterBuffer->format < QImage::NImageFormats); const QPixelLayout::BPP plBpp = qPixelLayouts[d->rasterBuffer->format].bpp; if (rotationType != NoRotation && qMemRotateFunctions[plBpp][rotationType] && img.rect().contains(sr.toAlignedRect())) {