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/1352353
Reviewed-by: Paul Jensen <[email protected]>
Commit-Queue: Raphael Kubo da Costa <[email protected]>
Cr-Commit-Position: refs/heads/master@{#611593}
diff --git a/net/dns/host_resolver_impl.cc b/net/dns/host_resolver_impl.cc
index 6411200f..70ea152 100644
--- a/net/dns/host_resolver_impl.cc
+++ b/net/dns/host_resolver_impl.cc
@@ -515,14 +515,23 @@
// DNS-over-HTTPS?
bool DnsServerSupportsDoh(const IPAddress& dns_server) {
static const base::NoDestructor<std::unordered_set<std::string>>
- upgradable_servers({
+ upgradable_servers(std::initializer_list<std::string>({
// 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
- "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
- "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()) !=
upgradable_servers->end();
}