mgehre/llvm-project

Misleading warning "returning a dangling pointer" for output parameters

mgehre opened this issue · 2 comments

On

bool f(int **p) {
    return true;
}

we diagnose warning: returning a dangling pointer [-Wlifetime] on the return statement. The warnings is supposed to be about p, which is considered an output parameter, but it can be quite confusing. The diagnostic should at least mention p and probably avoid the word returning.

See https://godbolt.org/z/5HliMv
fyi @Xazax-hun

This makes sense, thanks! I will create a better warning message for that.

Should be fixed in 5eb7821