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

Change "assert(false)" to "throw exception(...)" so it always fails, and also compiles properly with NDEBUG set #150

Merged
merged 1 commit into from
Nov 8, 2016

Conversation

mattr1
Copy link
Collaborator

@mattr1 mattr1 commented Nov 7, 2016

assert is replaced with nothing when compiling release (NDEBUG) code, breaking the compile (in MSVC at least) because the function doesn't return anything. Also, we really want this function to fail whether in debug or non-debug mode, so I think it's better to have assert(false) replaced by throw exception() instead. I don't know the proper exception for this situation.

@armatthews: Perhaps the number of invalid functions means the class hierarchy should be redesigned? It's a bit strange to have TreeLSTMBuilder be a RNNBuilder but have a bunch of functions that are not valid. Perhaps it could be:

class SomethingBuilder
class RNNBuilder : SomethingBuilder
class TreeLSTM: SomethingBuilder

Where the SomethingBuilder is just the subset of functions that are valid for treeLSTM also.

I don't fully understand why the functions aren't valid, so my opinion here might be way off.

@neubig neubig merged commit 82ad937 into clab:master Nov 8, 2016
@mattr1 mattr1 deleted the mattri/f1_assert branch February 10, 2017 02:04
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

Successfully merging this pull request may close these issues.

2 participants