[Bug other/31754] New: Include character count along line in error messages main.cpp:5:38
jg at jguk dot org
gcc-bugzilla@gcc.gnu.org
Sun Apr 29 12:55:00 GMT 2007
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
More information about the Gcc-bugs
mailing list