Commit 6e73ad4e authored by Raphael Kubo da Costa's avatar Raphael Kubo da Costa Committed by Commit Bot

dns: Explicitly use std::initializer_list with base::NoDestructor

This fixes the GCC build after 65be571f ("Add DNS histograms for private DNS
usage, perf, and auto-upgradability").

Due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84849, having
base::NoDestructor<T<U>> and passing an initializer list of Us does not
work if this is not done explicitly, as GCC incorrectly fails to determine
which constructor overload to use:

    ../../net/dns/host_resolver_impl.cc: In function ‘bool net::{anonymous}::DnsServerSupportsDoh(const net::IPAddress&)’:
    ../../net/dns/host_resolver_impl.cc:525:8: error: call of overloaded ‘NoDestructor(<brace-enclosed initializer list>)’ is ambiguous
           });
            ^
    In file included from ../../net/dns/host_resolver_impl.cc:42:
    ../../base/no_destructor.h:62:3: note: candidate: ‘base::NoDestructor<T>::NoDestructor(const base::NoDestructor<T>&) [with T = std::unordered_set<std::__cxx11::basic_string<char> >]’ <deleted>
       NoDestructor(const NoDestructor&) = delete;
       ^~~~~~~~~~~~
    ../../base/no_destructor.h:60:12: note: candidate: ‘base::NoDestructor<T>::NoDestructor(T&&) [with T = std::unordered_set<std::__cxx11::basic_string<char> >]’
       explicit NoDestructor(T&& x) { new (storage_) T(std::move(x)); }
                ^~~~~~~~~~~~
    ../../base/no_destructor.h:59:12: note: candidate: ‘base::NoDestructor<T>::NoDestructor(const T&) [with T = std::unordered_set<std::__cxx11::basic_string<char> >]’
       explicit NoDestructor(const T& x) { new (storage_) T(x); }
                ^~~~~~~~~~~~

See also: https://chromium-review.googlesource.com/c/chromium/src/+/1170905

Bug: 819294
Change-Id: I821c5215bf39c9c3caf50c614710dba551b0a19a
Reviewed-on: https://chromium-review.googlesource.com/c/1352353Reviewed-by: default avatarPaul Jensen <pauljensen@chromium.org>
Commit-Queue: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Cr-Commit-Position: refs/heads/master@{#611593}
parent e9a27271
...@@ -515,14 +515,23 @@ void MakeNotStale(HostCache::EntryStaleness* stale_info) { ...@@ -515,14 +515,23 @@ void MakeNotStale(HostCache::EntryStaleness* stale_info) {
// DNS-over-HTTPS? // DNS-over-HTTPS?
bool DnsServerSupportsDoh(const IPAddress& dns_server) { bool DnsServerSupportsDoh(const IPAddress& dns_server) {
static const base::NoDestructor<std::unordered_set<std::string>> static const base::NoDestructor<std::unordered_set<std::string>>
upgradable_servers({ upgradable_servers(std::initializer_list<std::string>({
// Google Public DNS // Google Public DNS
"8.8.8.8", "8.8.4.4", "2001:4860:4860::8888", "2001:4860:4860::8844", "8.8.8.8",
"8.8.4.4",
"2001:4860:4860::8888",
"2001:4860:4860::8844",
// Cloudflare DNS // Cloudflare DNS
"1.1.1.1", "1.0.0.1", "2606:4700:4700::1111", "2606:4700:4700::1001", "1.1.1.1",
"1.0.0.1",
"2606:4700:4700::1111",
"2606:4700:4700::1001",
// Quad9 DNS // Quad9 DNS
"9.9.9.9", "149.112.112.112", "2620:fe::fe", "2620:fe::9", "9.9.9.9",
}); "149.112.112.112",
"2620:fe::fe",
"2620:fe::9",
}));
return upgradable_servers->find(dns_server.ToString()) != return upgradable_servers->find(dns_server.ToString()) !=
upgradable_servers->end(); upgradable_servers->end();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment