Compiling this C++ program

extern int bar(int);
void foo() { bar(); }

gives me these error messages:

foo.cc: In function ‘void foo()’:
foo.cc:1: error: too few arguments to function ‘int bar(int)’
foo.cc:2: error: at this point in file

When using something like the emacs next-error command, this brings me to line
1 before line 2.  That is not useful.  With this sort of error the error is
almost always at line 2.

I actually don't think it's useful to report a message on line 1 at all.  The C
frontend does not report it.  We do not report it if there is a type error in
an argument.  When calling a function in a class or an overloaded function, we
report the function declaration after the error line.  If we do want to keep
reporting line 1 in this case, I certainly think it should be the second line
of the error message, not the first.


-- 
           Summary: Bad order of error messages for function call with wrong
                    number of arguments
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ian at airs dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38468

Reply via email to