Skip to content

General issue: How to resolve function of FunctionPointerCall? #21030

@pangodev91

Description

@pangodev91

Description of the issue

I want to resolve calls made with pointer variables, such as:

struct foo_struct {
	void (*foo)(void);
};

static void foo_func(void)
{
	printf("hello from foo_func\n");
}

static struct foo_struct bar_ops = {
	.foo = foo_func,
};

int main(void)
{
	// pointer call to foo_func
	struct foo_struct *ops_ptr = &bar_ops;
	ops_ptr->foo();

	// another pointer call to foo_func
	void (*ptr_call)(void);
	ptr_call = foo_func;
	ptr_call();

	return 0;
}

Why can't resolveCall from import semmle.code.cpp.ir.dataflow.ResolveCall resolve it?
Is there a solution available for this?
Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions