boostorg / boostorg/test

Can't directly compare optional<int> to nullopt under GCC

Open
#152 2 comments 0 reactions 1 assignee Claimed by @raffienficiaud View on GitHub
Dominant language
C++
Stars
213
Forks
149
Avg merge
18h 17m
Merged PRs (30d)
2

Description

The following code compiles under Clang but not under GCC:

~~~.cpp
#include
#include

BOOST_TEST_DONT_PRINT_LOG_VALUE( ::std::nullopt_t )
BOOST_TEST_DONT_PRINT_LOG_VALUE( ::std::optional )

BOOST_AUTO_TEST_CASE(y) {
BOOST_TEST( ::std::make_optional( 5 ) == ::std::nullopt );
}
~~~

I suspect that there's an issue with GCC's `std::is_constructible` needlessly explicitly instantiating `boost::test_tools::assertion::expression_base`'s `operator bool()` and I've raised [87093](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87093) about that.

However, (a) the GCC devs may well reject that issue and (b) I suspect it's workaround-able either way and it'd be really nice to be able to express this directly. Please can you look into this?

Thanks for all your work on this library.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.