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

Replace asserts with INVARIANT et al. to enable compilation with NDEBUG #1536

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/goto-programs/remove_returns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ bool remove_returnst::restore_returns(

if(i_it->is_goto())
{
goto_programt::const_targett target=i_it->get_target();
assert(target->is_end_function());
DATA_INVARIANT(i_it->get_target()->is_end_function(),
"goto after return value assignment is to end of function");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/util/sharing_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class sharing_nodet
subt &s=get_sub();
size_t r=s.erase(n);

_sn_assert(r==1);
CHECK_RETURN(r==1);
}

// container nodes
Expand Down
21 changes: 16 additions & 5 deletions unit/sharing_node.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*******************************************************************\

Module: Unit tests for sharing node

Author: Daniel Poetzl, [email protected]

\*******************************************************************/

/// \file
/// Unit tests for class sharing_nodet

#include <iostream>
#include <cassert>

Expand Down Expand Up @@ -30,7 +41,7 @@ void sharing_node_test()
assert(sn2.get_sub().size()==3);

p2=sn2.find_child(0);
assert(p2!=nullptr);
CHECK_RETURN(p2!=nullptr);

p2=sn1.find_child(0);
assert(p2!=nullptr);
Expand Down Expand Up @@ -62,7 +73,7 @@ void sharing_node_test()
p2=p1;

assert(p1->find_leaf("a")==nullptr);
assert(p2->find_leaf("a")==nullptr);
CHECK_RETURN(p2->find_leaf("a")==nullptr);

p1->place_leaf("a", "b");
assert(p2->get_container().size()==1);
Expand Down Expand Up @@ -114,15 +125,15 @@ void sharing_node_test()
assert(sn2.is_internal());

sn1.remove_child(0);
assert(sn1c.get_sub().size()==1);
INVARIANT(sn1c.get_sub().size()==1, "node has one child");

assert(sn2c.get_sub().size()==2);
INVARIANT(sn2c.get_sub().size()==2, "node has two children");
}
}

int main()
{
sharing_node_test();
sharing_node_test();

return 0;
}
Expand Down