r279514: buildworld failure: /usr/src/lib/libnv/tests/dnv_tests.cc:453:2: error: use of overloaded operator '<<' is ambiguous

Dimitry Andric dim at FreeBSD.org
Wed Mar 4 21:31:39 UTC 2015


On 04 Mar 2015, at 21:19, Dimitry Andric <dim at FreeBSD.org> wrote:
> 
> On 04 Mar 2015, at 18:18, O. Hartmann <ohartman at zedat.fu-berlin.de> wrote:
>> 
>> Am Wed, 4 Mar 2015 14:10:00 +0100
>> Dimitry Andric <dimitry at andric.com> schrieb:
>> 
>>> On 04 Mar 2015, at 12:31, O. Hartmann <ohartman at zedat.fu-berlin.de> wrote:
>>>> On Mon, 2 Mar 2015 08:58:05 -0500
>>>> Ryan Stone <rysto32 at gmail.com> wrote:
>>>> 
>>>>> Can you post the contents of your make.conf and src.conf?  I didn't
>>>>> see this in any of my "make tinderbox" runs
>>>>> _______________________________________________
>>>>> freebsd-current at freebsd.org mailing list
>>>>> http://lists.freebsd.org/mailman/listinfo/freebsd-current
>>>>> To unsubscribe, send any mail to "freebsd-current-unsubscribe at freebsd.org"
>>>> 
>>>> The culprit is the option
>>>> 
>>>> CXXFLAGS+=             -std=c++11
>>>> 
>>>> in /etc/src.conf
>>> 
>>> Right, it would be nice to have libnv compiling for C++11 though.  I'll have a look
>>> later today.
> ...
> 
> It is caused by the following test in lib/libnv/tests/dnv_tests.cc:
> 
> 	ATF_REQUIRE_EQ(actual_val, NULL);
> 
> In C++ mode, ATF_REQUIRE_EQ will attempt to output the value of NULL
> onto a std::ostringstream, but this has become ambiguous in C++11. [1]
> 
> The fix is to cast the NULL value to the specific pointer type ATF is
> testing against, 'nvlist_t *' in this case.  See the attached diff.

Hmm, I've now seen that there many more ATF_REQUIRE_EQ() instance in the
tests, which compare against NULL.  It is rather cumbersome to fix all
those, so maybe it should be fixed in atf-c++ instead.  Depending on
what may be allowed in the headers, something like this:

Index: contrib/atf/atf-c++/macros.hpp
===================================================================
--- contrib/atf/atf-c++/macros.hpp      (revision 279564)
+++ contrib/atf/atf-c++/macros.hpp      (working copy)
@@ -111,7 +111,8 @@
             std::ostringstream atfu_ss; \
             atfu_ss << "Line " << __LINE__ << ": " \
                     << #expected << " != " << #actual \
-                    << " (" << (expected) << " != " << (actual) << ")"; \
+                    << " (" << (expected) << " != " << \
+                    static_cast<__typeof(expected)>(actual) << ")"; \
             atf::tests::tc::fail(atfu_ss.str()); \
         } \
     } while (false)

However, that breaks several ATF_REQUIRE_EQ() instances in atf-c++
itself, like this:

/usr/src/contrib/atf/atf-c++/detail/process_test.cpp: In member function 'virtual void {anonymous}::atfu_tc_argv_array_init_varargs::body() const':
/usr/src/contrib/atf/atf-c++/macros.hpp:115:59: error: invalid static_cast from type 'std::__1::string {aka std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >}' to type 'const char*'
                     static_cast<__typeof(expected)>(actual) << ")"; \
                                                           ^
/usr/src/contrib/atf/atf-c++/detail/process_test.cpp:174:9: note: in expansion of macro 'ATF_REQUIRE_EQ'
         ATF_REQUIRE_EQ(argv[0], std::string("arg0"));
         ^

So in these cases, the 'expected' argument's type does not match the
'actual' argument's type.  It would be a bit of churn to fix all of
them...

I guess the easiest option is to forcibly disable C++11 if you are using
anything from atf-c++, until it is made C++11 compatible.

-Dimitry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/freebsd-current/attachments/20150304/6629f0c6/attachment.sig>


More information about the freebsd-current mailing list