f



error and warning

Are warnings equally dangerous like errors ????

What is the difference between errors and warnings ??
0
lipun4u (226)
1/14/2008 2:47:17 PM
comp.lang.c 30657 articles. 3 followers. spinoza1111 (3246) is leader. Post Follow

11 Replies
2964 Views

Similar Articles

[PageSpeed] 53

asit wrote:
> Are warnings equally dangerous like errors ????
Sometimes yes, sometimes even more dangerrous, sometimes less. Make sure you 
understand what the warning tries to tell you

> What is the difference between errors and warnings ??
Usualla errors prevent the compiler to finish it's work, while with warning 
that (usually) doesn't happen

Bye, Jojo 


0
nospam.jojo (1344)
1/14/2008 3:03:46 PM
In article <0f43d8bb-f186-4857-9fb3-32bcbe309bbc@f10g2000hsf.googlegroups.com>,
asit  <lipun4u@gmail.com> wrote:
>Are warnings equally dangerous like errors ????

It depends on the warning.
Some of them are harmless.  Many of them are more dangerous, since
careless programmers assume they're irrelevant, where errors obviously
need to be fixed.


>What is the difference between errors and warnings ??

If a compiler issues a warning, it probably thinks it can come up with
a sensible way to interpret what you gave it, or suspects that a
well-defined and unambiguous construct is nevertheless probably not
what you intended to say.
An error usually means the compiler is sufficiently confused (or the
code is sufficiently broken) to not be able to continue.

(Note that this is an implementation detail; the C language only
requires "diagnostics", and doesn't distinguish between errors and
warnings.)


dave

-- 
Dave Vandervies                                      dj3vande at eskimo dot com
I'd suggest that for all your connecting-to-the-ScourgeFromRedmond needs  [...]
Perhaps you might consider one of the many fine point-and-click interfaces
offered by your local gunshop?   --Anthony de Boer in the scary devil monastery
0
dj3vande3 (264)
1/14/2008 3:07:53 PM
On Jan 14, 9:47 am, asit <lipu...@gmail.com> wrote:
> Are warnings equally dangerous like errors ????
>
> What is the difference between errors and warnings ??

Errors tell you that what you've written is wrong and cant be done

Warnings tell you that what you've written is ambigious, and might not
do what you expect it to do.

0
lpitcher2 (882)
1/14/2008 3:08:58 PM
dj3va...@csclub.uwaterloo.ca.invalid wrote:
....
> (Note that this is an implementation detail; the C language only
> requires "diagnostics", and doesn't distinguish between errors and
> warnings.)

However, I've found that it's commonplace for mandatory diagnostics to
be reported as errors, while other diagnostics tend to be labeled as
warnings.
0
jameskuyper (5635)
1/14/2008 3:13:40 PM
asit said:

> Are warnings equally dangerous like errors ????
> 
> What is the difference between errors and warnings ??

An error message indicates a mistake in your code. A warning almost always 
indicates a mistake in your code. The C language doesn't distinguish 
between them - it only requires that, in certain circumstances, a 
"diagnostic message" is produced.

Over time, you will become familiar with diagnostic messages (what many 
implementations call "errors" and "warnings") and their causes, and you 
will learn how to deal with them. They can seem very baffling to the 
beginner, but they generally do make some kind of sense, although they are 
not always good at suggesting a fix. For example, for a message like 
"integer converted to pointer without a cast", the fix is probably *not* 
to add a cast - it is more likely that you forgot to #include a header.

You will learn fastest if you:

(a) set your compiler's warning level to the highest possible;
(b) deal with the *first* warning (or error) *first*. Mistakes of typing 
and punctuation frequently lead to a cascade of messages because the 
compiler has been totally confused by the typo. If you find yourself 
facing dozens of errors, fixing the first message first and then 
re-compiling will very often remove a great many of them at one stroke.

-- 
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
0
rjh (10790)
1/14/2008 3:17:58 PM
Joachim Schmitz wrote:
> asit wrote:
>> Are warnings equally dangerous like errors ????
> Sometimes yes, sometimes even more dangerrous, sometimes less. Make
> sure you understand what the warning tries to tell you
>
>> What is the difference between errors and warnings ??
> Usualla errors prevent the compiler to finish it's work, while with
> warning that (usually) doesn't happen
From your other article I gather that you a) use GCC abd b) are pretty new 
to C
, so here's an extra hint:
uase gcc's option -Wall -Werror. While -Wall givesa a pretty complete set of 
warnings (not all possible ones, but a reasonable subset) -Werror causes 
them to be treated as errors (and hence the gcc refuses to compile the 
code).
In this group you may also consider using -ansi -pedantic, to get extra 
warnings for everything beond the C-Standard.
And as said earlier: only warning you fully understand may get ignored, so 
better don't ignore any, but rewrite your code instead.

Bye, Jojo 


0
nospam.jojo (1344)
1/14/2008 3:18:08 PM
jameskuyper@verizon.net writes:
> dj3va...@csclub.uwaterloo.ca.invalid wrote:
> ...
>> (Note that this is an implementation detail; the C language only
>> requires "diagnostics", and doesn't distinguish between errors and
>> warnings.)
>
> However, I've found that it's commonplace for mandatory diagnostics to
> be reported as errors, while other diagnostics tend to be labeled as
> warnings.

But that's not universal.  For example, gcc often issues mere warnings
for constraint violations, presuambly if the authors thought they
could construct a reasonable interpretation for the code.

-- 
Keith Thompson (The_Other_Keith) <kst-u@mib.org>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
0
kst-u (21963)
1/14/2008 5:49:07 PM
On Jan 14, 6:47=A0am, asit <lipu...@gmail.com> wrote:
> Are warnings equally dangerous like errors ????
>
> What is the difference between errors and warnings ??

Generally, the compiler refuses to emit code with an error and will
still emit code with a warning.

For that reason, warnings are usually more dangerous than errors,
because you can ignore warnings (perhaps unwisely) but you can't
ignore errors.

Finally, something that causes no diagnostic at all is likely to be
the most serious sort of problem.  It could be a logic error or
undefined behavior or the programmer casting away an important
warning.
0
dcorbit (2696)
1/14/2008 10:19:50 PM
Joachim Schmitz wrote, On 14/01/08 15:18:
> Joachim Schmitz wrote:
>> asit wrote:
>>> Are warnings equally dangerous like errors ????
>> Sometimes yes, sometimes even more dangerrous, sometimes less. Make
>> sure you understand what the warning tries to tell you
>>
>>> What is the difference between errors and warnings ??
>> Usualla errors prevent the compiler to finish it's work, while with
>> warning that (usually) doesn't happen
> From your other article I gather that you a) use GCC abd b) are pretty new 
> to C
> , so here's an extra hint:
> uase gcc's option -Wall -Werror. While -Wall givesa a pretty complete set of 
> warnings (not all possible ones, but a reasonable subset) -Werror causes 
> them to be treated as errors (and hence the gcc refuses to compile the 
> code).
> In this group you may also consider using -ansi -pedantic, to get extra 
> warnings for everything beond the C-Standard.

I think you meant using -ansi -pedantic to get all the diagnostics 
*required* by the C standard. It is -Wall and -Wextra that give you 
warnings beyond those required by the C standard.

> And as said earlier: only warning you fully understand may get ignored, so 
> better don't ignore any, but rewrite your code instead.

Please note that you have to understand the warning *before* fixing your 
code. For example adding a cast because that looks like what the warning 
is suggesting is almost always the wrong thing to do.
-- 
Flash Gordon
0
spam331 (4048)
1/15/2008 12:08:34 AM
Flash Gordon wrote:
> Joachim Schmitz wrote, On 14/01/08 15:18:
>> Joachim Schmitz wrote:
>>> asit wrote:
>>>> Are warnings equally dangerous like errors ????
>>> Sometimes yes, sometimes even more dangerrous, sometimes less. Make
>>> sure you understand what the warning tries to tell you
>>>
>>>> What is the difference between errors and warnings ??
>>> Usualla errors prevent the compiler to finish it's work, while with
>>> warning that (usually) doesn't happen
>> From your other article I gather that you a) use GCC abd b) are
>> pretty new to C
>> , so here's an extra hint:
>> uase gcc's option -Wall -Werror. While -Wall givesa a pretty
>> complete set of warnings (not all possible ones, but a reasonable
>> subset) -Werror causes them to be treated as errors (and hence the
>> gcc refuses to compile the code).
>> In this group you may also consider using -ansi -pedantic, to get
>> extra warnings for everything beond the C-Standard.
>
> I think you meant using -ansi -pedantic to get all the diagnostics
> *required* by the C standard. It is -Wall and -Wextra that give you
> warnings beyond those required by the C standard.
Well, I meant warning about things that are non-standard

>> And as said earlier: only warning you fully understand may get
>> ignored, so better don't ignore any, but rewrite your code instead.
>
> Please note that you have to understand the warning *before* fixing
> your code. For example adding a cast because that looks like what the
> warning is suggesting is almost always the wrong thing to do.
Indeed

bye, Jojo 


0
nospam.jojo (1344)
1/15/2008 8:49:31 AM
Joachim Schmitz wrote, On 15/01/08 08:49:
> Flash Gordon wrote:
>> Joachim Schmitz wrote, On 14/01/08 15:18:

<snip>

>>> In this group you may also consider using -ansi -pedantic, to get
>>> extra warnings for everything beond the C-Standard.
>> I think you meant using -ansi -pedantic to get all the diagnostics
>> *required* by the C standard. It is -Wall and -Wextra that give you
>> warnings beyond those required by the C standard.
> Well, I meant warning about things that are non-standard

<snip>

OK, I miss-understood what you intended to say. So now I'll address what 
you intended...

Adding -ansi -pedantic will, in some senses, not warn about everything 
that is non-standard. For example it still will not warn about all 
instances of undefined behaviour (-ansi -pedantic -Wall -Wextra comples 
closer, but still is not complete) since doing so would be equivalent to 
the halting problem.
-- 
Flash Gordon
0
spam331 (4048)
1/15/2008 7:03:06 PM
Reply: