This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/26997] New: g++ reports incorrect error message when the identifier with error occurs earlier on the same line
- From: "pavel dot petrovic at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Apr 2006 08:35:49 -0000
- Subject: [Bug c++/26997] New: g++ reports incorrect error message when the identifier with error occurs earlier on the same line
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The program below reports the following compiler errors:
bug.cpp:17: error: expected primary-expression before '*' token
bug.cpp:17: error: expected primary-expression before ')' token
bug.cpp:17: error: expected `;' before 'malloc'
which seem to refer to the first occurence of identifier "t"
on the line 17. However, that is a correct occurence.
The mistake is later on the line, but the error message
of the compiler is misleading. This is not a serious issue...
$ uname -a
Linux ... 2.6.12-1-386 #1 Tue Sep 27 12:41:08 JST 2005 i686 GNU/Linux
$ g++ --version
g++ (GCC) 4.0.3 (Debian 4.0.3-1)
libc6: 2.3.6-3
libstdc++6 4.0.3-1
-------------------------------------------
#include <stdlib.h>
typedef struct { int a; int b; } t;
int main()
{
t v1, *v2;
t *v3;
v2 = &v1;
v1.a = 2;
// correct code:
//v3 = (t *)malloc(sizeof(t) * v2->a);
// code with a mistake:
v3 = (t *)malloc(sizeof(t) * t->a);
return 0;
}
-------------------------------------
--
Summary: g++ reports incorrect error message when the identifier
with error occurs earlier on the same line
Product: gcc
Version: 4.0.3
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pavel dot petrovic at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26997