public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/26997]  New: g++ reports incorrect error message when the identifier with error occurs earlier on the same line
@ 2006-04-03  8:35 pavel dot petrovic at gmail dot com
  2006-04-03 15:34 ` [Bug c++/26997] g++ reports misleading " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: pavel dot petrovic at gmail dot com @ 2006-04-03  8:35 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-10-29 16:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-03  8:35 [Bug c++/26997] New: g++ reports incorrect error message when the identifier with error occurs earlier on the same line pavel dot petrovic at gmail dot com
2006-04-03 15:34 ` [Bug c++/26997] g++ reports misleading " pinskia at gcc dot gnu dot org
2006-04-03 16:04 ` pavel dot petrovic at gmail dot com
2006-04-18  3:47 ` bangerth at dealii dot org
2008-10-26  1:43 ` manu at gcc dot gnu dot org
2008-10-26  1:59 ` manu at gcc dot gnu dot org
2008-10-29 16:06 ` manu at gcc dot gnu dot org
2008-10-29 16:07 ` manu at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).