Skip to content

Commit 1716704

Browse files
committed
Fix the bad_func_object.cpp test.
1 parent 8b25bea commit 1716704

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

test/error/bad_func_object.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,21 @@
22
using namespace Halide;
33

44
int main() {
5-
const Internal::Function func{};
6-
const Func f{func}; // internal_assert
5+
#ifdef HALIDE_WITH_EXCEPTIONS
6+
try {
7+
#endif
8+
const Internal::Function func{};
9+
const Func f{func}; // internal_assert
710

8-
std::cout << f.name() << "\n"; // segfaults without above assert
11+
std::cout << f.name() << "\n"; // segfaults without above assert
12+
#ifdef HALIDE_WITH_EXCEPTIONS
13+
} catch (const InternalError &e) {
14+
// The harness rejects internal errors as they should typically not be
15+
// _expected_. However, we are directly testing a constructor invariant
16+
// check here, so an internal error is both expected and appropriate.
17+
throw std::runtime_error(e.what());
18+
}
19+
#endif
920

1021
printf("Success!\n");
1122
return 0;

0 commit comments

Comments
 (0)