diff --git a/src/sysinfo.cc b/src/sysinfo.cc index 41e36a13..2520ad5a 100644 --- a/src/sysinfo.cc +++ b/src/sysinfo.cc @@ -73,22 +73,14 @@ BENCHMARK_NORETURN void PrintErrorAndDie(Args&&... args) { #ifdef BENCHMARK_HAS_SYSCTL -#ifdef __GNUC__ -// Suppress the warning generated by the C11 flexible array member below. -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wpedantic" -#endif - /// ValueUnion - A type used to correctly alias the byte-for-byte output of /// `sysctl` with the result type it's to be interpreted as. struct ValueUnion { union DataT { uint32_t uint32_value; uint64_t uint64_value; - // FIXME (Maybe?): This is a C11 flexible array member, and not technically - // C++. However, all compilers support it and it allows for correct aliasing - // of union members from bytes. - char bytes[]; + // For correct aliasing of union members from bytes. + char bytes[8]; }; using DataPtr = std::unique_ptr<DataT, decltype(&std::free)>; @@ -137,10 +129,6 @@ struct ValueUnion { } }; -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif - ValueUnion GetSysctlImp(std::string const& Name) { size_t CurBuffSize = 0; if (sysctlbyname(Name.c_str(), nullptr, &CurBuffSize, nullptr, 0) == -1) @@ -177,7 +165,7 @@ bool GetSysctl(std::string const& Name, std::array<Tp, N>* Out) { if (!Buff) return false; *Out = Buff.GetAsArray<Tp, N>(); return true; -}; +} #endif template <class ArgT>