https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119850
Bug ID: 119850 Summary: #pragma GCC diagnostic ignored "-Wstrict-overflow" is ignored Product: gcc Version: 14.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: peppe at gcc dot gnu.org Target Milestone: --- Wrapping a function that raises -Wstrict-overflow with #pragma GCC diagnostic ignored does not suppress the relative warning. #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstrict-overflow" #include <nlohmann/json.hpp> #pragma GCC diagnostic pop int main() { using json = nlohmann::json; json j = json::parse(R"( { "pi": 3.141e2, "happy": true } )"); std::string s = j.dump(4); } On GCC 14.2, with -Wall -Wextra -Wstrict-overflow=3, this still emits a warning: <source>: In function 'nlohmann::json_v3_11_1::detail::dtoa_impl::cached_power nlohmann::json_v3_11_1::detail::dtoa_impl::get_cached_power_for_binary_exponent(int)': <source>:19:1: warning: assuming signed overflow does not occur when changing X +- C1 cmp C2 to X cmp C2 -+ C1 [-Wstrict-overflow] 19 | } | ^ Even if one wraps the entire file (not just the header) with the pragma, the warning is not suppressed (!). The fact that the header is in a -isystem path doesn't affect anything (but that seems to be by design, PR119388). One can reduce the testcase by picking the function out of nlohmann-json). You can find both the original and the reduction here: https://gcc.godbolt.org/z/hTWMdjq7b