llvm / llvm/llvm-project

Enhancement: add a warning for possibly unintended pointer overload calls (e.g. calling `foo(int*)` instead of `foo(int)`)

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

Description

The warning could have prevented the bug fixed in https://github.com/llvm/llvm-project/pull/165056.

This is a proposal for a new diagnostic that could detect possibly unintended calls to pointer overloads when a value overload also exists.

Consider the following code:

```
void foo(int);
void foo(int*);

void test() {
int x = 123;
int *p = &x;

foo(p); // probably intended: foo(*p);
}
```

This code is valid and unambiguous. However, in some situations, this pattern reflects a common user mistake: the programmer meant to dereference the pointer but forgot the `*`.

Contributor guide

Open the contributing guide

Research direction

No source files, tests, or entry points are named. Start by reading the example and the linked pull request that motivated the proposal, then identify the compiler diagnostic area involved. Done means agreeing on the conditions for detecting this valid-but-possibly-unintended overload call and adding a warning with suitable diagnostic coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.