]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
test-dnsname_cc.cc: Fix a 'temporary used in loop' warning reported by g++ 11.1.0
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 19 May 2021 17:23:24 +0000 (19:23 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 19 May 2021 17:23:24 +0000 (19:23 +0200)
```
test-dnsname_cc.cc: In member function ‘void test_dnsname_cc::test_compare_canonical::test_method()’:
test-dnsname_cc.cc:684:26: warning: loop variable ‘b’ of type ‘const string&’ {aka ‘const std::__cxx11::basic_string<char>&’} binds to a temporary constructed from type ‘const char* const’ [-Wrange-loop-construct]
  684 |   for(const std::string& b : {"bert.com.", "alpha.nl.", "articles.xxx.",
      |                          ^
test-dnsname_cc.cc:684:26: note: use non-reference type ‘const string’ {aka ‘const std::__cxx11::basic_string<char>’} to make the copy explicit or ‘const char* const&’ to prevent copying
```

pdns/test-dnsname_cc.cc

index cc80a0fab8d9c3bb32eacbd45df3a05c9f12500c..af1b2571c16987b0403751e965c360110e67af7c 100644 (file)
@@ -681,7 +681,7 @@ BOOST_AUTO_TEST_CASE(test_compare_canonical) {
   BOOST_CHECK(!a(DNSName("www.powerdns.net"), g_rootdnsname));
 
   vector<DNSName> vec;
-  for(const std::string& b : {"bert.com.", "alpha.nl.", "articles.xxx.",
+  for(const char* b : {"bert.com.", "alpha.nl.", "articles.xxx.",
        "Aleph1.powerdns.com.", "ZOMG.powerdns.com.", "aaa.XXX.", "yyy.XXX.", 
        "test.powerdns.com.", "\\128.com"}) {
     vec.push_back(DNSName(b));