Skip to content

Conversation

@tony-mak
Copy link
Contributor

@tony-mak tony-mak commented Sep 24, 2020

Hi folks

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.

What do you think?

Thanks!

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.
@s-yata s-yata merged commit 006020c into s-yata:master Sep 26, 2020
@s-yata
Copy link
Owner

s-yata commented Sep 26, 2020

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants