From 6cc830f7a66684c2193a70ec9446ba4a6972dc63 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 9 Jul 2021 14:25:36 +0200 Subject: [PATCH] tst_QFile: fix GCC -Wignored-qualifiers The decltype() of a const auto variable will be const T, for some T. GCC warns that in the static_cast, said const is ignored. Fix by not casting, but declaring a variable of fitting type. Add a scope so the next reader doesn't have to go hunting for further uses of 'readResult' or, now, 'expected'. Change-Id: Iebc828a522810c6f2514fb3542d8c76c755ec7a5 Reviewed-by: Edward Welbourne --- tests/auto/corelib/io/qfile/tst_qfile.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index c67579967b..83a706e81d 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -2899,8 +2899,11 @@ void tst_QFile::handle() QVERIFY(fd > 2); QCOMPARE(int(file.handle()), fd); char c = '\0'; - const auto readResult = QT_READ(int(file.handle()), &c, 1); - QCOMPARE(readResult, static_cast(1)); + { + const auto readResult = QT_READ(int(file.handle()), &c, 1); + decltype(readResult) expected = 1; + QCOMPARE(readResult, expected); + } QCOMPARE(c, '/'); // test if the QFile and the handle remain in sync