From 1219359a2062d9e532a6d3a375992f221c023291 Mon Sep 17 00:00:00 2001 From: Sergey Mitrofanov Date: Wed, 3 Jan 2024 05:59:43 -0500 Subject: [PATCH] Disable "-Wmaybe-uninitialized" diagnostic for some lines of code due to GCC11 false positive --- groups/ntc/ntcdns/ntcdns_client.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/groups/ntc/ntcdns/ntcdns_client.cpp b/groups/ntc/ntcdns/ntcdns_client.cpp index 641797d5..7074631b 100644 --- a/groups/ntc/ntcdns/ntcdns_client.cpp +++ b/groups/ntc/ntcdns/ntcdns_client.cpp @@ -812,13 +812,22 @@ void ClientGetDomainNameOperation::processResponse( timeToLive.makeValue(answer.ttl()); } else { - bsl::size_t timeToLiveValue = timeToLive.value(); + const bsl::size_t timeToLiveValue = timeToLive.value(); if (timeToLiveValue != answer.ttl()) { NTCDNS_CLIENT_OPERATION_LOG_TTL_MISMATCH(answer.ttl(), timeToLiveValue); +// Some versions of GCC erroneously warn when 'timeToLive.value()' is +// called even when protected by a check of '!timeToLive.isNull()'. +#if defined(BSLS_PLATFORM_CMP_GNU) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif if (answer.ttl() < timeToLiveValue) { timeToLive = answer.ttl(); } +#if defined(BSLS_PLATFORM_CMP_GNU) +#pragma GCC diagnostic pop +#endif } }