From c1152ca0620a0826fbff304313bd1b195f7d677c Mon Sep 17 00:00:00 2001 From: Martchus Date: Thu, 12 May 2022 20:09:28 +0200 Subject: [PATCH] Ignore warning about possible null pointer dereferences appearing with GCC 12 Not sure why this warning is occurring but it is likely incorrect --- io/misc.cpp | 7 +++++++ tests/iotests.cpp | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/io/misc.cpp b/io/misc.cpp index 61f9cdd..25114d5 100644 --- a/io/misc.cpp +++ b/io/misc.cpp @@ -37,7 +37,14 @@ std::string readFile(std::string_view path, std::string_view::size_type maxSize) } res.reserve(size); file.seekg(ios_base::beg); + // ignore warning about null pointer dereference from GCC 12 for now (which is *likely* not correct) +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-Wnull-dereference" +#endif res.assign((istreambuf_iterator(file)), istreambuf_iterator()); +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif return res; } diff --git a/tests/iotests.cpp b/tests/iotests.cpp index d3f4919..3da0587 100644 --- a/tests/iotests.cpp +++ b/tests/iotests.cpp @@ -446,7 +446,14 @@ void IoTests::testAdvancedIniFile() std::string originalContents; inputFile.clear(); inputFile.seekg(std::ios_base::beg); + // ignore warning about null pointer dereference from GCC 12 for now (which is *likely* not correct) +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-Wnull-dereference" +#endif originalContents.assign((istreambuf_iterator(inputFile)), istreambuf_iterator()); +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif CPPUNIT_ASSERT_EQUAL(originalContents, newFile.str()); }