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

gsl::fail_fast not found in the namespace #988

Closed
ahmadsadeed opened this issue Jul 8, 2021 · 2 comments
Closed

gsl::fail_fast not found in the namespace #988

ahmadsadeed opened this issue Jul 8, 2021 · 2 comments

Comments

@ahmadsadeed
Copy link

I posted it as question on SO, but no answer yet:

In this simple use of C++ contracts, I get the error: no type named 'fail_fast' in namespace 'gsl'. Will try block throw the fast_fail exception or some other exception?

#define GSL_THROW_ON_CONTRACT_VIOLATION
#include <gsl/gsl>
#include <iostream>


int main(void)
{
    try {
        Expects(false);
    }
    catch(const gsl::fail_fast &e) {
        std::cout << "exception: " << e.what() << '\n';
    }
}
@JordanMaples
Copy link
Contributor

gsl::fail_fast and GSL_THROW_ON_CONTRACT_VIOLATION was removed from the GSL with #831.

A false evaluation of Expects or Ensures results in program termination.

@JordanMaples
Copy link
Contributor

I also replied to your issue on StackOverflow. I'll add the full response here that I gave on SO for completeness:

GSL_THROW_ON_CONTRACT_VIOLATION and gsl::fast_fail were removed from the Microsoft GSL starting with release v3.0.0. All contract violations result in a call to std::terminate unless you are building in kernel mode for MSVC where it invokes __fastfail.

There was a period of time where gsl::fast_fail was defined only when GSL_THROW_ON_CONTRACT_VIOLATION was defined, however that was identified in #267 and subsequently fixed in #268.

Context for the above point: there are comments on the OP suggesting that gsl::fast_fail was not being defined because GSL_THROW_ON_CONTRACT_VIOLATION was not defined in the correct place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants