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

Use MARISA_DEBUG_IF in scoped-*.h as opposed to MARISA_THROW_IF #1

Closed
wants to merge 6 commits into from

Conversation

tony-mak
Copy link

With this change, developers can take the marisa library without being forced to enable exceptions for their whole library / application by using "-fexceptions". However, some projects decide to not to enable exceptions.

The reason that we have to enable exceptions for the whole application/library is that the marisa library throws exceptions in header files. If we don't enable exceptions, there will be two implementations of those functions that throw. This violates the ODR.

There are only two places where we throw exceptions from header files in non-debug mode.
IMO, it might be reasonable to use MARISA_DEBUG_IF there instead of MARISA_THROW_IF.

Also, I think the new behavior is also closer to unique_ptr::reset.
From cppreference:

A test for self-reset, i.e. whether ptr points to an object already managed by *this, is not performed, except where provided as a compiler extension or as a debugging assert.

MARISA_DEBUG_IF is like the debugging assert that it mentions.

See s-yata#32

s-yata and others added 6 commits September 17, 2020 09:18
These are the only two places that we throw exceptions from header files
in non-debug mode.

With this change, developers can take the marisa library without being
forced to enable exceptions for their whole library / application.

IMO, self-reset does not seem to be fatal enough to throw in production
and MARISA_DEBUG_IF should be enough for us to catch it if we think it
should never happen.
@jmr
Copy link

jmr commented Sep 28, 2020

This has been merged upstream, so you can close this and do a clean update to upstream.

s-yata@006020c

@tony-mak tony-mak closed this Sep 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants