By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,332 Members | 1,404 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,332 IT Pros & Developers. It's quick & easy.

Compiler Warnings

P: n/a
I'm new to c and gcc. I was wondering if anyone can point me to a web page
or book that has a list of the warning messages and their meanings.

Are the warnings the same no matter what compiler you use, or are they
different for each compiler? I have looked all over the gcc web site, but I
can't find anything that explains what the warnings are.

If someone could take the time to help me out and direct me to some info
about this, I'd appriciate it.

Thanks

Nov 14 '05 #1
Share this Question
Share on Google+
20 Replies


P: n/a
"News" <ja****@hotmail.com> writes:
I'm new to c and gcc. I was wondering if anyone can point me to a web page
or book that has a list of the warning messages and their meanings.
Unlike some compilers' warnings, GCC's are meant to be
self-explanatory. There isn't a place, that I know of, which has
the explanations you are looking for.

If there is a specific warning, or a few, that you would like
explained, c.l.c is a good place to ask. Note that c.l.c is
generally not the right place to ask questions about specific
compilers, but warnings tend to be more about C than about
compilers.
Are the warnings the same no matter what compiler you use, or are they
different for each compiler? I have looked all over the gcc web site, but I
can't find anything that explains what the warnings are.


Every compiler has different warnings.
--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}
Nov 14 '05 #2

P: n/a
Ben Pfaff wrote:


Every compiler has different warnings.


This is true in two different senses: first, the actual text that is
emitted for a given condition may be different. Second, the choice
whether or not to emit a warning for some condition may be different.

In other words, code that causes one compiler to generate a warning may
cause a different compiler to generate a different warning or no warning
at all.

The standard requires certain conditions to generate a diagnostic, so
some conditions must evoke some form of warning from a
standard-compliant compiler.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
Nov 14 '05 #3

P: n/a
Ben Pfaff wrote:
"News" <ja****@hotmail.com> writes:
I'm new to c and gcc. I was wondering if anyone can point me to a web page
or book that has a list of the warning messages and their meanings.

Unlike some compilers' warnings, GCC's are meant to be
self-explanatory. There isn't a place, that I know of, which has
the explanations you are looking for.


IBM, at least for the mainframes, and even for other systems, has a
tradition of supplying manuals describing all the messages a given
program could generate. Usually it will describe in more detail than
the printed message the cause, and suggested action to take.

There may be other companies that have a similar system, but it is
not so common. Though I believe that early microsoft compilers
may have done it.

-- glen

Nov 14 '05 #4

P: n/a
glen herrmannsfeldt wrote:

<snip>
IBM, at least for the mainframes, and even for other systems, has a
tradition of supplying manuals describing all the messages a given
program could generate. Usually it will describe in more detail than
the printed message the cause, and suggested action to take.


I have fond (but admittedly vague) memories of these messages:

I40008291 An error has occurred.

Suggested action: Correct the error and re-submit the job.

;-)

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 14 '05 #5

P: n/a
Thank you guys for the info. I remember when I was a kid my father would
have a pocket size book full of warnings he could look at if anything came
up. Like they say, I just have to keep coding and making mistakes, then I
will get less warnings, and also get familiar with what they are. Thanks
again
Nov 14 '05 #6

P: n/a
Jakle wrote:
Thank you guys for the info. I remember when I was a kid my father would
have a pocket size book full of warnings he could look at if anything came
up. Like they say, I just have to keep coding and making mistakes, then I
will get less warnings, and also get familiar with what they are. Thanks
again

Why not train yourself, by making deliberate mistakes and watching what the
compiler does? For example, try leaving a semicolon off a declaration. Or
try using an undefined variable. Or try missing out a necessary header.

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 14 '05 #7

P: n/a
Richard Heathfield wrote:

(snip)
Why not train yourself, by making deliberate mistakes and watching what the
compiler does? For example, try leaving a semicolon off a declaration. Or
try using an undefined variable. Or try missing out a necessary header.


I remember a compiler I used to use (not a C compiler) that would
attempt to correct errors. (In the internal representation of the
source program only.) So it had messages like:

Semicolon missing, one inserted in line 123.

In the days of batch programming, it was useful to get as much
out of a compiler run as possible. This would allow the
compiler to get farther through the program, and find more
errors, before giving up.

I don't remember if it could detect unclosed comments, an easy
mistake to make in languages with multiline comments.

-- glen

Nov 14 '05 #8

P: n/a
Richard Heathfield wrote:
glen herrmannsfeldt wrote:

<snip>
IBM, at least for the mainframes, and even for other systems, has a
tradition of supplying manuals describing all the messages a given
program could generate. Usually it will describe in more detail than
the printed message the cause, and suggested action to take.

I have fond (but admittedly vague) memories of these messages:

I40008291 An error has occurred.

Suggested action: Correct the error and re-submit the job.


Yes, some were like that. It does remind me, though, of the time
my program died with a Machine Check error on a system that charged
real money for CPU time, lines printed, etc. It took some
convincing to get credit for a problem that was not my fault.

Machine Check is a hardware error in the processor, that the
processor can detect. Memory parity might be one, though they
usually checked more than that.

-- glen

Nov 14 '05 #9

P: n/a
"News" <ja****@hotmail.com> wrote in message
news:BR******************@news1.news.adelphia.net. ..
I'm new to c and gcc. I was wondering if anyone can point me to a web page
or book that has a list of the warning messages and their meanings.
The content and meanings of compiler warning (and error) messages
are unique to each compiler.

Are the warnings the same no matter what compiler you use,

No.
or are they
different for each compiler?
Yes.
I have looked all over the gcc web site, but I
can't find anything that explains what the warnings are.
I suggest you read more closely :-). I'm sure the gcc manual
has these descriptions.

Also, if you have some code that's producing a warning you don't
understand, you can post it here and others will probably be able
to spot the trouble. But only post enough code to demonstrate the
problem.

If someone could take the time to help me out and direct me to some info
about this, I'd appriciate it.


Any questions about gcc, I'd direct to the gnu web site and/or newsgroups.

-Mike
Nov 14 '05 #10

P: n/a
Jakle <ja****@hotmail.com> spoke thus:
Thank you guys for the info. I remember when I was a kid my father would
(etc)


In the future, please include the relevant text of the person you are
replying to and make your own comments below it. It's considered
good manners here.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #11

P: n/a
Richard Heathfield <do******@address.co.uk.invalid> spoke thus:
I40008291 An error has occurred.
Suggested action: Correct the error and re-submit the job.


About as helpful as "No ROM BASIC, system halted"...

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #12

P: n/a
Kevin Goodsell <us*********************@neverbox.com> spoke thus:
The standard requires certain conditions to generate a diagnostic, so
some conditions must evoke some form of warning from a
standard-compliant compiler.


When the appropriate compiler options are enabled, of course, i.e.
-ansi for gcc.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 14 '05 #13

P: n/a
In <O3LCb.40792$8y1.172456@attbi_s52> glen herrmannsfeldt <ga*@ugcs.caltech.edu> writes:
Richard Heathfield wrote:

(snip)
Why not train yourself, by making deliberate mistakes and watching what the
compiler does? For example, try leaving a semicolon off a declaration. Or
try using an undefined variable. Or try missing out a necessary header.


I remember a compiler I used to use (not a C compiler) that would
attempt to correct errors. (In the internal representation of the
source program only.) So it had messages like:

Semicolon missing, one inserted in line 123.


VAX C used to do that. The warning codename was SEMICOLONADDED.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #14

P: n/a
In <as****************@newsread1.news.pas.earthlink.n et> Kevin Goodsell <us*********************@neverbox.com> writes:
The standard requires certain conditions to generate a diagnostic, so
some conditions must evoke some form of warning from a
standard-compliant compiler.


Nope, they must evoke some form of diagnostic. It's up to the implementor
to decide whether each specific condition is handled as a warning or as
an error.

IMO, users would be better served by compilers that handled each and
every required diagnostic as an error, reserving warnings for dubious
program constructs that don't require a diagnostic.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #15

P: n/a
In article <br**********@chessie.cirr.com>,
Christopher Benson-Manica <at***@nospam.cyberspace.org> wrote:
Kevin Goodsell <us*********************@neverbox.com> spoke thus:
The standard requires certain conditions to generate a diagnostic, so
some conditions must evoke some form of warning from a
standard-compliant compiler.
When the appropriate compiler options are enabled, of course, i.e.
-ansi for gcc.


Without the appropriate options, it's not a standard-compliant compiler.

F'rexample, "gcc" without any options specified is a Rather Different
compiler than "gcc -W -Wall -ansi -pedantic -O".
dave

--
Dave Vandervies dj******@csclub.uwaterloo.ca your a morron.

Beautiful. Classic sig block material.
--Richard Heathfield roasts a troll in comp.lang.c
Nov 14 '05 #16

P: n/a
glen herrmannsfeldt <ga*@ugcs.caltech.edu> writes:
[...]
I remember a compiler I used to use (not a C compiler) that would
attempt to correct errors. (In the internal representation of the
source program only.) So it had messages like:

Semicolon missing, one inserted in line 123.


The (non-C) compiler I used to work on did something similar. It
internally corrected any syntax errors until it managed to build a
syntactically correct representation of the input program. (This was
done only for error recovery; syntax errors, even correctable ones,
were considered fatal.)

If you fed it garbage (e.g., a file of English text), it would usually
reduce it to nothing, recognizing any keywords along the way.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
(Note new e-mail address)
Nov 14 '05 #17

P: n/a
In <br**********@chessie.cirr.com> Christopher Benson-Manica <at***@nospam.cyberspace.org> writes:
Kevin Goodsell <us*********************@neverbox.com> spoke thus:
The standard requires certain conditions to generate a diagnostic, so
some conditions must evoke some form of warning from a
standard-compliant compiler.


When the appropriate compiler options are enabled, of course, i.e.
-ansi for gcc.


It's actually -pedantic that enables most of the required diagnostics that
gcc doesn't generate by default. gcc -ansi is a conforming translator,
except for the diagnostics issue. For "full" conformance, you need
-ansi -pedantic. I used the double quotes because even with these
options there are floating point issues left, some of which can be cured
by -ffloat-store (at the expense of slowing down the generated code).

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #18

P: n/a
In message <br**********@sunnews.cern.ch>
Da*****@cern.ch (Dan Pop) wrote:
IMO, users would be better served by compilers that handled each and
every required diagnostic as an error, reserving warnings for dubious
program constructs that don't require a diagnostic.


I agree with Dan totally on this point (for once), and that's what the
compiler I maintain tries to ensure. Every required diagnostic is an error or
serious error. Warnings are only advisory. Undefined behaviour may lead to
either or neither.

This means that the "implicit int" diagnostic is an error in C99 mode too. It
used to be a warning.

I don't know how I'd have coped learning C if I hadn't originally learnt on
such a compiler.

--
Kevin Bracey, Principal Software Engineer
Tematic Ltd Tel: +44 (0) 1223 503464
182-190 Newmarket Road Fax: +44 (0) 1223 503458
Cambridge, CB5 8HE, United Kingdom WWW: http://www.tematic.com/
Nov 14 '05 #19

P: n/a
In message <ln************@nuthaus.mib.org>
Keith Thompson <ks***@mib.org> wrote:
glen herrmannsfeldt <ga*@ugcs.caltech.edu> writes:
[...]
I remember a compiler I used to use (not a C compiler) that would
attempt to correct errors. (In the internal representation of the
source program only.) So it had messages like:

Semicolon missing, one inserted in line 123.


The (non-C) compiler I used to work on did something similar. It
internally corrected any syntax errors until it managed to build a
syntactically correct representation of the input program.


The C compiler I maintain does pretty much exactly this, and will correct
most simple errors. It does bail out and skip until a terminator in the
event of a serious parse failure though.

For example, feeding it your last paragraph gives:

"c.x", line 1: Error: expected ')' or ',' - inserted ')' before '-'
"c.x", line 1: Error: function prototype formal 'non' needs type or class - 'int' assumed
"c.x", line 1: Error: declaration lacks type (assuming 'int'): 'The'
"c.x", line 1: Error: expected ';' or ',' - inserted ';' before '-'
"c.x", line 1: Serious error: Expecting <declarator> or <type> but found '-'
"c.x", line 4: Error: expected ';' or ',' - inserted ';' before <eof>

So it corrected it to

The (non);-C) ... program.;

And then interpreted it as

int The(int non);

--
Kevin Bracey, Principal Software Engineer
Tematic Ltd Tel: +44 (0) 1223 503464
182-190 Newmarket Road Fax: +44 (0) 1223 503458
Cambridge, CB5 8HE, United Kingdom WWW: http://www.tematic.com/
Nov 14 '05 #20

P: n/a
On Sun, 14 Dec 2003 18:14:21 GMT, "Mike Wahler"
<mk******@mkwahler.net> wrote:
<snip>
The content and meanings of compiler warning (and error) messages
are unique to each compiler.
Yes.
<snip>
I have looked all over the gcc web site, but I
can't find anything that explains what the warnings are.


I suggest you read more closely :-). I'm sure the gcc manual
has these descriptions.

No, the GCC documentation does not contain descriptions of the
diagnostic messages as such. Some diagnostics are controlled by flags
(-W*) because they are (though) less likely to really be problems, and
the descriptions of these flags do explain to some extent the meaning
of the related diagnostics, but not their exact wording.

I don't recall anyone who made a practice of actually releasing
documentation of "error" or diagnostic or similar messages but IBM
(already mentioned) and DEC.
Also, if you have some code that's producing a warning you don't
understand, you can post it here and others will probably be able
to spot the trouble. But only post enough code to demonstrate the
problem.

Yes, except the usual advice is to post the smallest "possible" (or at
least the smallest you can find) *complete* program. Posting just
excerpts of code often omits information that turns out to be vital.

- David.Thompson1 at worldnet.att.net
Nov 14 '05 #21

This discussion thread is closed

Replies have been disabled for this discussion.