From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10456 invoked by alias); 3 Apr 2006 08:35:51 -0000 Received: (qmail 10443 invoked by uid 48); 3 Apr 2006 08:35:49 -0000 Date: Mon, 03 Apr 2006 08:35:00 -0000 Subject: [Bug c++/26997] New: g++ reports incorrect error message when the identifier with error occurs earlier on the same line X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "pavel dot petrovic at gmail dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-04/txt/msg00147.txt.bz2 List-Id: 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 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