Ignore warning about possible null pointer dereferences appearing with GCC 12

Not sure why this warning is occurring but it is likely incorrect
This commit is contained in:
Martchus 2022-05-12 20:09:28 +02:00
parent f46855b130
commit c1152ca062
2 changed files with 14 additions and 0 deletions

View File

@ -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<char>(file)), istreambuf_iterator<char>());
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
return res;
}

View File

@ -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<char>(inputFile)), istreambuf_iterator<char>());
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
CPPUNIT_ASSERT_EQUAL(originalContents, newFile.str());
}