Skip to content
Draft
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <stdio.h>

int main()
{
return 0;
}
10 changes: 10 additions & 0 deletions regression/goto-analyzer/reachable-functions-stdio-empty/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CORE
test.c
--reachable-functions
test\.c main [0-9]+ [0-9]+$
<built-in-additions> __CPROVER_initialize [0-9]+ [0-9]+$
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
__sputc
15 changes: 9 additions & 6 deletions src/goto-analyzer/unreachable_instructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,12 @@ void unreachable_instructions(

const symbolt &decl = ns.lookup(gf_entry.first);

if(
called.find(decl.name) != called.end() ||
to_code_type(decl.type).get_inlined())
// Only consider functions reachable if they're actually called.
// Previously, functions marked as "inline" were automatically treated as
// reachable, but this caused false positives on systems (like MacOS) where
// system headers contain uncalled inline functions that reference other
// functions, making those referenced functions appear reachable.
if(called.find(decl.name) != called.end())
{
unreachable_instructions(goto_program, dead_map);
}
Expand Down Expand Up @@ -314,9 +317,9 @@ static void list_functions(
{
const symbolt &decl = ns.lookup(gf_entry.first);

if(
unreachable == (called.find(decl.name) != called.end() ||
to_code_type(decl.type).get_inlined()))
// Only consider functions reachable if they're actually called.
// See comment in unreachable_instructions() for rationale.
if(unreachable == (called.find(decl.name) != called.end()))
{
continue;
}
Expand Down
Loading