This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/82755] New: Misleading error message "incompatible type for argument"
- From: "Keith.S.Thompson at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 27 Oct 2017 23:55:14 +0000
- Subject: [Bug c/82755] New: Misleading error message "incompatible type for argument"
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82755
Bug ID: 82755
Summary: Misleading error message "incompatible type for
argument"
Product: gcc
Version: 7.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: Keith.S.Thompson at gmail dot com
Target Milestone: ---
I'm using gcc 7.2.0-8ubuntu3 on Ubuntu 17.10, x86_64.
$ cat c.c
void f(double a) { }
int main(void) {
int i;
f(&i);
}
$ gcc -c -std=c11 -pedantic c.c
c.c: In function ‘main’:
c.c:5:7: error: incompatible type for argument 1 of ‘f’
f(&i);
^
c.c:1:6: note: expected ‘double’ but argument is of type ‘int *’
void f(double a) { }
^
The problem is the phrase "incompatible type" in the error message. It's true
that the types int* and double are incompatible, but that's not why the call
is invalid. Types int and double are also incompatible (as the C standard
defines the term), but the call
f(42);
would be valid.
I suggest changing "incompatible type" to "incorrect type".