llvm / llvm/llvm-project

catch function argument evaluation order bugs with -Wsometimes-uninitialized

Open
#165,875 0 comments 0 reactions 0 assignees View on GitHub
clang:diagnostics
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Consider something like:

```
int init(int* p);
void g(int a, int b);

void f(void) {
int x;
g(init(&x), x);
}
```

Assuming that `init` initializes `*p`, `x` may or may not be initialized in the call to `g` depending on the order in which the function call arguments are evaluated, which is unspecified.

Catching order of evaluation bugs in general is tricky, but in cases like this, it seems `-Wsometimes-uninitialized` could warn.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the C example with the compiler's existing -Wsometimes-uninitialized warning behavior. Investigate the warning's handling of function-call argument evaluation, then add coverage showing that the order-dependent use of x is diagnosed without changing unrelated cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.