Often we have compile errors on long lines of code, it is time-consuming to
find the actual character offset on the long line which is causing the error.
Sometimes it is even necessary to separate out long if(..) statements, so we
can figure out which part of the long line has the problem in the error
message.

Could gcc indicate the character offset along the line? Not sure how easy this
would be to do, but perhaps the code which is generating the error has the
character offset along the line.

For example, see this obvious example code build below:
$ g++ -Wall -o t main.cpp
main.cpp: In function ‘int main()’:
main.cpp:9: error: wrong type argument to unary minus


character 38 is the start of the erroneous unary minus, so the error message
could be clearer as:
$ g++ -Wall -o t main.cpp
main.cpp: In function ‘int main()’:
main.cpp:9:38 error: wrong type argument to unary minus

Example program follows:
========================
// g++ -Wall -o t main.cpp
#include <string.h>
#include <cstdio>
int main()
{
        char * buf0;
        char * buf1;
        char * buf2;
        if((buf0 = strdup("buf0")) && (buf1 +- strdup("buf1")) && (buf2 =
strdup("buf2")))
        {
                printf("All strings duplicated\n");
        }

        return 0;
}
=============================

I am running GNU C++ version 4.1.2 20060928 (prerelease) (Ubuntu
4.1.1-13ubuntu5) (i486-linux-gnu)


-- 
           Summary: Include character count along line in error messages
                    main.cpp:5:38
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jg at jguk dot org
 GCC build triplet: i486-linux-gnu
  GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu


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

Reply via email to