473,320 Members | 1,947 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Compendiums of compiler warning/error messages mapped to actual codeproblems?

Do any of you happen to have links to compendiums (or heaven forbid, an
actual manual) which maps compiler warnings and errors to examples of
actual code problems? In this case I'm specifically looking for one
for gcc. The general problem is of course that the compiler messages
must be short, and that tends to make them so cryptic that it isn't
always immediately obvious what the problem is. It almost makes me long
for the days when the IBM compilers would describe the problem with just
a number - which wasn't useful in and of itself, but was quite helpful
given the umpteen page messages manual which contained excellent
descriptions of each problem, indexed by that number.

Anyway, this comes up (again) because I just figured out that the gcc error:

foo.c:351: error: two or more data types in declaration specifiers

Which was cited for this line (the first prototype):

void handle_message(char *string);

was actually the result of the immediately preceding struct definition:

struct datastructure{
int this;
int that;
/*etc. all valid *
}
^ note the missing semicolon after the closing brace.

In this instance the message was not completely devoid of useful
information, since it at least localized the issue to the vicinity of
line 351, even if the actual error was on the first non blank line
preceding it. The message though - not too helpful. Why not "did not
find expected semicolon"? For this particular message google wasn't
all that helpful - in the first few results it turned up examples of the
message but not an explanation of what caused it.

Regards,

David Mathog
Jan 10 '08 #1
6 2247
On Jan 10, 12:53*pm, David Mathog <mat...@caltech.eduwrote:
Do any of you happen to have links to compendiums (or heaven forbid, an
actual manual) which maps compiler warnings and errors to examples of
actual code problems? *In this case I'm specifically looking for one
for gcc. *The general problem is of course that the compiler messages
must be short, and that tends to make them so cryptic that it isn't
always immediately obvious what the problem is. *It almost makes me long
for the days when the IBM compilers would describe the problem with just
a number - which wasn't useful in and of itself, but was quite helpful
given the umpteen page messages manual which contained excellent
descriptions of each problem, indexed by that number.

Anyway, this comes up (again) because I just figured out that the gcc error:

foo.c:351: error: two or more data types in declaration specifiers

Which was cited for this line (the first prototype):

void *handle_message(char *string);

was actually the result of the immediately preceding struct definition:

struct datastructure{
* *int this;
* *int that;
* */*etc. all valid *}

* ^ note the missing semicolon after the closing brace.

In this instance the message was not completely devoid of useful
information, since it at least localized the issue to the vicinity of
line 351, even if the actual error was on the first non blank line
preceding it. *The message though - not too helpful. Why not "did not
find expected semicolon"? *For this particular message google wasn't
all that helpful - in the first few results it turned up examples of the
message but not an explanation of what caused it.

Regards,

David Mathog
to answer your last question first, and in defense of compiler writers
everywhere:
It is not always possible to determine what is expected as the next
token in the input stream of the compiler. Keep in mind a good
compiler must accept all valid source code AND flag invalid code. The
point at which a compiler detects an error may be, as you know, far
from the actual cause of the problem.

aside from that, I think an errors manual written this way would be
very VERY helpful!
Ed
Jan 10 '08 #2
David Mathog wrote:
Do any of you happen to have links to compendiums (or heaven forbid, an
actual manual) which maps compiler warnings and errors to examples of
actual code problems? In this case I'm specifically looking for one
for gcc. The general problem is of course that the compiler messages
must be short, and that tends to make them so cryptic that it isn't
always immediately obvious what the problem is. It almost makes me long
for the days when the IBM compilers would describe the problem with just
a number - which wasn't useful in and of itself, but was quite helpful
given the umpteen page messages manual which contained excellent
descriptions of each problem, indexed by that number.
Back in Bright College Days, a couple friends managed to
patch the FORTRAN compiler so that the text of every error
message was the single word "WRONG." But they showed mercy by
leaving the message ID intact, so you saw "NA201E - WRONG" and
could at least go to the manual and look up NA201E.
Anyway, this comes up (again) because I just figured out that the gcc
error:

foo.c:351: error: two or more data types in declaration specifiers

Which was cited for this line (the first prototype):

void handle_message(char *string);

was actually the result of the immediately preceding struct definition:

struct datastructure{
int this;
int that;
/*etc. all valid *
}
^ note the missing semicolon after the closing brace.
A couple of FAQ answers come pretty close to diagnosing this
problem, although none seems to get exactly this manifestation.
In this instance the message was not completely devoid of useful
information, since it at least localized the issue to the vicinity of
line 351, even if the actual error was on the first non blank line
preceding it. The message though - not too helpful. Why not "did not
find expected semicolon"? For this particular message google wasn't
all that helpful - in the first few results it turned up examples of the
message but not an explanation of what caused it.
It's perhaps a bit too much to ask that the compiler diagnose
the problem as "missing semicolon," since inserting a semicolon
is not the only transformation that would make the source valid.
For example, "extraneous `void'" is equally plausible, since
removing `void' would produce a valid declaration. In general,
a given invalid source may be "near" in an edit-distance sense
to several different valid sources, so describing the error in
terms of "the" correction that would fix it amounts to choosing
between those valid alternatives -- which amounts to reading the
programmer's mind.

I take some pleasure in the activity of pondering a c.l.c.
question and trying to answer it in the questioner's terms. This
involves looking behind the question itself and trying to imagine
what confusion or misconception led the questioner to ask it, and
then to come up with an explanation that addresses the underlying
problem. Thus, "You forgot to allocate space for the string's
terminating zero" instead of "Add one to the malloc() argument;"
the latter answers the "How do I fix it?" question, but the
former is more helpful. I think our computers will continue to
emit messages of the latter kind for the foreseeable future,
and that messages of the "sympathetic analysis" kind will remain
the province of humans who learned the hard way.

--
Er*********@sun.com
Jan 10 '08 #3
David Mathog wrote:
Do any of you happen to have links to compendiums (or heaven forbid, an
actual manual) which maps compiler warnings and errors to examples of
actual code problems? In this case I'm specifically looking for one
for gcc. The general problem is of course that the compiler messages
must be short, and that tends to make them so cryptic that it isn't
always immediately obvious what the problem is. It almost makes me long
for the days when the IBM compilers would describe the problem with just
a number - which wasn't useful in and of itself, but was quite helpful
given the umpteen page messages manual which contained excellent
descriptions of each problem, indexed by that number.

Anyway, this comes up (again) because I just figured out that the gcc
error:

foo.c:351: error: two or more data types in declaration specifiers

Which was cited for this line (the first prototype):

void handle_message(char *string);

was actually the result of the immediately preceding struct definition:

struct datastructure{
int this;
int that;
/*etc. all valid *
}
^ note the missing semicolon after the closing brace.

In this instance the message was not completely devoid of useful
information, since it at least localized the issue to the vicinity of
line 351, even if the actual error was on the first non blank line
preceding it. The message though - not too helpful. Why not "did not
find expected semicolon"? For this particular message google wasn't
all that helpful - in the first few results it turned up examples of the
message but not an explanation of what caused it.

Regards,

David Mathog

This is a quality of implementation issue...

For instance this program
struct datastructure{
int this;
int that;
}

int main(void)
{
}

provokes with lcc-win:
Error twarn.c: 6 missing semicolon after structure declaration
Warning twarn.c: 6 multiple use of 'int'
1 error, 1 warning

Better isn't it?

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Jan 10 '08 #4
jacob navia <ja***@nospam.comwrites:
For instance this program
struct datastructure{
int this;
int that;
}

int main(void)
{
}

provokes with lcc-win:
Error twarn.c: 6 missing semicolon after structure declaration
Warning twarn.c: 6 multiple use of 'int'
The warning here does not make any sense: `int' is only used once
in this declaration (except inside the struct definition--but
that's clearly not what the warning talks about).
--
char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]
={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa6 7f6aaa,0xaa9aa9f6,0x11f6},*p
=b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
2:{i++;if(i)break;else default:continue;if(0)case 1:putchar(a[i&15]);break;}}}
Jan 11 '08 #5
jacob navia wrote:
This is a quality of implementation issue...

For instance this program
struct datastructure{
int this;
int that;
}

int main(void)
{
}

provokes with lcc-win:
Error twarn.c: 6 missing semicolon after structure declaration
Warning twarn.c: 6 multiple use of 'int'
1 error, 1 warning

Better isn't it?
Actually, it's an abomination. "Multiple use of 'int'" has no
relationship to the problem with this code. It is wrong and completely
unhelpful.

The gcc diagnostics for this code are much more to the point:

a.c:6: error: two or more data types in declaration specifiers
a.c:7: warning: return type of 'main' is not 'int'

There are numerous nice features of lcc-win. This bogus diagnostic is
not one of them.
Jan 11 '08 #6
In article <f4**********************************@v4g2000hsf.g ooglegroups.com>,
Ed Prochak <ed*******@gmail.comwrote:
>It is not always possible to determine what is expected as the next
token in the input stream of the compiler. Keep in mind a good
compiler must accept all valid source code AND flag invalid code. The
point at which a compiler detects an error may be, as you know, far
from the actual cause of the problem.
Long ago I used an compiler in which almost every error message was
followed by the suggestion "missing semicolon?". It was often right.

-- Richard
--
:wq
Jan 11 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: M P | last post by:
What does this mean? I am accessing an ASP page that queries Access Database thru fileDSN. I'm using IIS 5.0 Win2K SP4 Microsoft OLE DB Provider for ODBC Drivers error '80004005' General...
5
by: Patrick Coleman | last post by:
Hi, This may seem to be a basic question, but I keep getting the following error: main.cc:93: undefined reference to `AT_UrlParser::AT_UrlParser(char const*, std::basic_string<char,...
6
by: paul calvert | last post by:
I hope somewhere here has encountered and solved a similar problem in the past. 1) on a new Win2000 PC: installed Visual C++ 6.0 download & install single file Service Pack 5.0 2) try to...
10
by: forgotten field | last post by:
Hi,how are you? I have been studying C++ by myself, but recently I am having a real problem. I am learning about the basic usage of a doubly linked list using polymorphism. However, I have got the...
19
by: Alf P. Steinbach | last post by:
// As usual the error message directs one to the report the bug. // // And as usual there is absolutely no way to do so without paying for // the privilege... // // Or using three or four hours...
7
by: Matthew Del Buono | last post by:
Don't try to solve the problem. I've found a way -- around or fixing it. I'm just curious as to whether this is Microsoft's problem in their compiler or if there's a standard saying this is to be...
13
by: junky_fellow | last post by:
N869, Page 47, "Except when it is the operand of the sizeof operator or the unary & operator, or is a string literal used to initialize an array, an expression that has type ''array of type'' is...
45
by: alertjean | last post by:
Or may be I am stubborn or dumb ... of not putting in a * in the typecast. This is code I am worrying about long long b=1; int *address ; address=(int)&b; printf ("%x %x...
18
by: andreas.luethi | last post by:
Hi All Compile a our source with BM XL C/C++ Enterprise Edition V8.0 for AIX (Version: 08.00.0000.0000) produces a lot of Informational message like this: "aaalib.c", line 671.1: 1506-412 (I)...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.