misc: Turn off 'maybe-uninitialized' warn for regex include (#696)

https://github.com/gem5/gem5/pull/636 triggered a bug with the GCC
compiler and its interaction with the CPP stdlib regex library, outlined
here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105562.

This was causing the gem5 Compiler tests to fail for GCC-12:
https://github.com/gem5/gem5/actions/runs/7219055796

This fix turns off the 'maybe-unitialized' warning when we include the
regex headers in "src/kern/linux/helpers.cc".
This commit is contained in:
Bobby R. Bruce
2023-12-20 13:10:56 -08:00
committed by GitHub
parent 4f5d4b9baf
commit 2f58f1c87b

View File

@@ -37,7 +37,27 @@
#include "kern/linux/helpers.hh"
/* The following pragmas are to fix a bug in GCC \w the CPP standard library,
* outlined here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105562.
* This ignores the 'maybe-unitialized' warning when importing regex for
* GCC 12.1.
*/
// ignore 'maybe-uniitialized' warnings for GCC 12.1.
#if __GNUC__ && __GNUC__ == 12 && __GNUC_MINOR__ == 1
#if __has_warning( "-Wmaybe-uninitialized" )
#define SUPPRESSING_MAYBE_UNINITIALIZED_WARNING
// save diagnostic state.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
#endif
#include <regex>
#ifdef SUPPRESSING_MAYBE_UNINITIALIZED_WARNING
// restore the diagnostic state.
#pragma GCC diagnostic pop
#endif
#include <string>
#include <type_traits>
#include <vector>