Skip to content

Commit c9c60cf

Browse files
gmgunterGitHub Enterprise
authored andcommitted
Fix debug builds (#981)
Fix an issue that caused debug builds to fail due to an invalid operation (<bool> && <std::string>) inside assert statements. The code was modified to first stream debug info to a pyre::journal::firewall_t channel prior to the assertion. These assertions are in vendored code from ortools, anyway, so we don't expect to trip them in isce3.
1 parent 622a552 commit c9c60cf

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

cxx/isce3/unwrap/ortools/max_flow.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,13 @@ bool GenericMaxFlow<Graph>::CheckRelabelPrecondition(NodeIndex node) const {
312312
it.Next()) {
313313
#ifndef NDEBUG
314314
const ArcIndex arc = it.Index();
315-
assert(!IsAdmissible(arc) && DebugString("CheckRelabelPrecondition:", arc));
315+
if (IsAdmissible(arc)) {
316+
pyre::journal::firewall_t channel("isce3.unwrap.ortools.max_flow");
317+
channel << pyre::journal::at(__HERE__)
318+
<< DebugString("CheckRelabelPrecondition:", arc)
319+
<< pyre::journal::endl;
320+
}
321+
assert(!IsAdmissible(arc));
316322
#endif
317323
}
318324
return true;

cxx/isce3/unwrap/ortools/min_cost_flow.cc

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,13 @@ bool GenericMinCostFlow<Graph, ArcFlowType, ArcScaledCostType>::
268268
it.Next()) {
269269
#ifndef NDEBUG
270270
const ArcIndex arc = it.Index();
271-
assert(!IsAdmissible(arc) && DebugString("CheckRelabelPrecondition:", arc));
271+
if (IsAdmissible(arc)) {
272+
pyre::journal::firewall_t channel("isce3.unwrap.ortools.min_cost_flow");
273+
channel << pyre::journal::at(__HERE__)
274+
<< DebugString("CheckRelabelPrecondition:", arc)
275+
<< pyre::journal::endl;
276+
}
277+
assert(!IsAdmissible(arc));
272278
#endif
273279
}
274280
return true;
@@ -489,8 +495,16 @@ GenericMinCostFlow<Graph, ArcFlowType, ArcScaledCostType>::FastReducedCost(
489495
assert(node_potential_[Tail(arc)] == tail_potential);
490496
assert(graph_->IsNodeValid(Tail(arc)));
491497
assert(graph_->IsNodeValid(Head(arc)));
492-
assert(node_potential_[Tail(arc)] <= 0 && DebugString("ReducedCost:", arc));
493-
assert(node_potential_[Head(arc)] <= 0 && DebugString("ReducedCost:", arc));
498+
#ifndef NDEBUG
499+
if (node_potential_[Tail(arc)] > 0 || node_potential_[Head(arc)] > 0) {
500+
pyre::journal::firewall_t channel("isce3.unwrap.ortools.min_cost_flow");
501+
channel << pyre::journal::at(__HERE__)
502+
<< DebugString("ReducedCost:", arc)
503+
<< pyre::journal::endl;
504+
}
505+
#endif
506+
assert(node_potential_[Tail(arc)] <= 0);
507+
assert(node_potential_[Head(arc)] <= 0);
494508
return scaled_arc_unit_cost_[arc] + tail_potential -
495509
node_potential_[Head(arc)];
496510
}

0 commit comments

Comments
 (0)