[bind10-dev] Compilation failure on master with g++

Michal 'vorner' Vaner michal.vaner at nic.cz
Sat Jun 25 12:09:37 UTC 2011


Hello

Current master fails to compile for me (with g++ 4.5.2 on Gentoo):
run_unittests-ip_check_unittest.o: In function `isc::acl::IPCheck<(anonymous namespace)::GeneralAddress>::getAddress() const':
/home/vorner/work/bind10/src/lib/acl/tests/../../../../src/lib/acl/ip_check.h:258: undefined reference to `isc::acl::IPCheck<(anonymous namespace)::GeneralAddress>::IPV4_SIZE'
/home/vorner/work/bind10/src/lib/acl/tests/../../../../src/lib/acl/ip_check.h:258: undefined reference to `isc::acl::IPCheck<(anonymous namespace)::GeneralAddress>::IPV6_SIZE'
run_unittests-ip_check_unittest.o: In function `isc::acl::IPCheck<(anonymous namespace)::GeneralAddress>::getMask() const':
/home/vorner/work/bind10/src/lib/acl/tests/../../../../src/lib/acl/ip_check.h:264: undefined reference to `isc::acl::IPCheck<(anonymous namespace)::GeneralAddress>::IPV4_SIZE'
/home/vorner/work/bind10/src/lib/acl/tests/../../../../src/lib/acl/ip_check.h:264: undefined reference to `isc::acl::IPCheck<(anonymous namespace)::GeneralAddress>::IPV6_SIZE'
run_unittests-ip_check_unittest.o: In function `isc::acl::IPCheck<(anonymous namespace)::GeneralAddress>::setMask(int)':
/home/vorner/work/bind10/src/lib/acl/tests/../../../../src/lib/acl/ip_check.h:362: undefined reference to `isc::acl::IPCheck<(anonymous namespace)::GeneralAddress>::IPV4_SIZE'
/home/vorner/work/bind10/src/lib/acl/tests/../../../../src/lib/acl/ip_check.h:362: undefined reference to `isc::acl::IPCheck<(anonymous namespace)::GeneralAddress>::IPV6_SIZE'

After looking at it, I found out that the compiler is correct according to this:
http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8a.doc%2Flanguage%2Fref%2Fcplr038.htm
(down at the page, last 3 paragraphs).

I tried to provide the definitions, but it fails with static const template
members for some reason.

I also noticed the constants are not template dependant at all, so having a
different instance for each template parameter is wasteful.

Therefore I propose this patch to fix the compilation and wastefulness. It has
the disadvantage that the IPV?_SIZE symbols are visible, but I didn't come with
a better solution that would work for my compiler.

Is it OK to push? I don't want to create a ticket for such small thing, but
there is nobody online on jabber right now.

Thanks

-- 
BOFH Excuse #452:
Somebody ran the operating system through a spelling checker.

Michal 'vorner' Vaner
-------------- next part --------------
commit fda9986ba6b50e22640c8bcea989192fd0dcb8ec
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Sat Jun 25 14:02:09 2011 +0200

    Fix compilation with new g++

diff --git a/src/lib/acl/ip_check.h b/src/lib/acl/ip_check.h
index 844d06a..89db4f7 100644
--- a/src/lib/acl/ip_check.h
+++ b/src/lib/acl/ip_check.h
@@ -80,7 +80,13 @@ splitIPAddress(const std::string& ipprefix);
 
 } // namespace internal
 
+// Size of uint8_t array needed to hold different address types
+const size_t IPV6_SIZE = sizeof(struct in6_addr);
+const size_t IPV4_SIZE = sizeof(struct in_addr);
 
+// Confirm our assumption of relative sizes - this allows us to assume that
+// an array sized for an IPv6 address can hold an IPv4 address.
+BOOST_STATIC_ASSERT(IPV6_SIZE > IPV4_SIZE);
 
 /// \brief IP Check
 ///
@@ -93,15 +99,6 @@ splitIPAddress(const std::string& ipprefix);
 
 template <typename Context>
 class IPCheck : public Check<Context> {
-private:
-    // Size of uint8_t array needed to hold different address types
-    static const size_t IPV6_SIZE = sizeof(struct in6_addr);
-    static const size_t IPV4_SIZE = sizeof(struct in_addr);
-
-    // Confirm our assumption of relative sizes - this allows us to assume that
-    // an array sized for an IPv6 address can hold an IPv4 address.
-    BOOST_STATIC_ASSERT(IPV6_SIZE > IPV4_SIZE);
-
 public:
     /// \brief String Constructor
     ///
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <https://lists.isc.org/pipermail/bind10-dev/attachments/20110625/86883161/attachment.bin>


More information about the bind10-dev mailing list