Skip to content

Commit f429962

Browse files
committed
Add some null asserts, closes #1134
Adding `assert(object_type);` silences a null-dereference warning when compiling cppfront on GCC 14 using -Werror=nonnull -O2 (both switches together) Running all regression tests doesn't fire the assertion, but it's good hygiene to have it there anyway. GCC could be diagnosing a real error that I don't see, and that happens not to be exercised by the regression tests. At least now with the assertion we'll get a clear ICE to track down, if we ever do encounter a source file where it does fire.
1 parent 893c9aa commit f429962

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

source/sema.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1518,9 +1518,13 @@ class sema
15181518
auto check(parameter_declaration_node const& n)
15191519
-> bool
15201520
{
1521+
assert(n.declaration);
1522+
15211523
auto type_name = std::string{};
15221524
if (n.declaration->has_declared_return_type()) {
1523-
type_name = n.declaration->get_object_type()->to_string();
1525+
auto object_type = n.declaration->get_object_type();
1526+
assert(object_type);
1527+
type_name = object_type->to_string();
15241528
}
15251529

15261530
if (

0 commit comments

Comments
 (0)