Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix variant detection with non-clang compiler #1511

Merged
merged 1 commit into from
Jan 26, 2019

Conversation

robinmoussu
Copy link
Contributor

I noticed that stringification support for std::variant isn't activated if your compiler is gcc or clang >= 8. This should correct it.

@robinmoussu
Copy link
Contributor Author

robinmoussu commented Jan 25, 2019

Using gcc9 (not tested with other compilers), when the C++17 mode is activated, the following test fails:

../projects/SelfTest/UsageTests/ToStringVariant.tests.cpp:37: FAILED:
  REQUIRE( value.valueless_by_exception() )
with expansion:
  false

I don't understand why however.

For reference:

 30     SECTION("valueless by exception") {
 31         struct sample {
 32             operator int() const { throw 42; }
 33         };
 34
 35         type value{1.5f};
 36         REQUIRE_THROWS_AS( value.emplace<int>(sample{}), int );
 37         REQUIRE( value.valueless_by_exception() );
 38         CHECK( "{valueless variant}" == ::Catch::Detail::stringify(value) );
 39     }

@codecov
Copy link

codecov bot commented Jan 25, 2019

Codecov Report

Merging #1511 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #1511   +/-   ##
=======================================
  Coverage   80.53%   80.53%           
=======================================
  Files         121      121           
  Lines        3436     3436           
=======================================
  Hits         2767     2767           
  Misses        669      669

1 similar comment
@codecov
Copy link

codecov bot commented Jan 25, 2019

Codecov Report

Merging #1511 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #1511   +/-   ##
=======================================
  Coverage   80.53%   80.53%           
=======================================
  Files         121      121           
  Lines        3436     3436           
=======================================
  Hits         2767     2767           
  Misses        669      669

horenmar pushed a commit that referenced this pull request Jan 26, 2019
By using non-trivially copyable types, we force libstdc++-9's variant to
properly enter the valueless-by-exception state for our stringification
test.

Related to #1511
@horenmar
Copy link
Member

The problem with the test has been solved in a different PR.

@horenmar horenmar merged commit 50fefd0 into catchorg:master Jan 26, 2019
@robinmoussu robinmoussu deleted the fix/variant branch January 26, 2019 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants