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

Compiler warnings vs remarks mystery

P: n/a
gil
Hi,

I'm trying to find the best way to work with compiler warnings. I'd
like to remove *all* warnings from the code, and playing around with
the warning level, I've noticed that compiling with /W3 I get warnings
that with /W4 are shown as remarks, e.g.:

warning #177: variable "Foo" was declared but never referenced

....is displayed as a "remark #177" with /W4. That doesn't fit the
definitions in Intel's help page. My questions are:

1. Why did the warning turn into a remark, is this a bug? If not, what
is the intention behind this behaviour? This doesn't include ALL
warnings, e.g.

warning #504: initial value of reference to non-const must be an
lvalue

remains a warning with /W4.

2. How come issues of conversion from "double" to "float" are
displayed only as remarks with w4? Usually they are w3 with other
compilers...?

3. Can remarks be eliminated altogether, and what is the best way (in
your opinion) to go with remarks/warnings?

Thanks,
Gil Moses.

Jun 25 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
gi*@waves.com wrote:
I'm trying to find the best way to work with compiler warnings. I'd
like to remove *all* warnings from the code, and playing around with
the warning level, I've noticed that compiling with /W3 I get warnings
that with /W4 are shown as remarks, e.g.:

warning #177: variable "Foo" was declared but never referenced

...is displayed as a "remark #177" with /W4. That doesn't fit the
definitions in Intel's help page. My questions are:

1. Why did the warning turn into a remark, is this a bug? If not, what
is the intention behind this behaviour? This doesn't include ALL
warnings, e.g.

warning #504: initial value of reference to non-const must be an
lvalue

remains a warning with /W4.

2. How come issues of conversion from "double" to "float" are
displayed only as remarks with w4? Usually they are w3 with other
compilers...?

3. Can remarks be eliminated altogether, and what is the best way (in
your opinion) to go with remarks/warnings?
Your questions concern the behaviour of a particular compiler. Those
aspects are not set forth by the language Standard, they are at the
discretion of any compiler manufacturer/vendor. Please contact Intel
technical support and ask *them* about those things.

IMO the best way to eliminate the warnings is to write perfect code.
Since perfection is [usually] unattainable, it is allowed to disable
warnings if there is no way to get rid of them, or just ignore them
if there is a desire to see that your code is not perfect (from the
compiler creators' point of view).

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 25 '07 #2

P: n/a
gi*@waves.com wrote:
I'm trying to find the best way to work with compiler warnings. I'd
like to remove *all* warnings from the code, and playing around with
the warning level, I've noticed that compiling with /W3 I get warnings
that with /W4 are shown as remarks
The Standard doesn't define such things as "remarks" or "warnings". All
the Standard requires is that the compiler issue "diagnostics" for
certain problems with your code. However, it doesn't define what form
the diagnostic should take. For all the Standard requires, the
diagnostic can just say, "Problem!" without specifying what it is;
however, that would be a Quality of Implementation (QoI) issue and few
people would be likely to use that compiler.

What I'm trying to say is that you need to ask the support group for
your specific compiler.

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Jun 25 '07 #3

P: n/a
On Jun 25, 2:15 pm, g...@waves.com wrote:
I'm trying to find the best way to work with compiler warnings. I'd
like to remove *all* warnings from the code,
That's generally a good goal, but all of the compilers I've used
have one or two idiotic warnings, which can't reasonably be
avoided. (More than one compiler I've used has output warnings
from its own header files:-).) At the very least, be sure you
understand why the warning is there.

In a larger project, it's generally a good idea to start with
the rule that all code must be compiled at the maximum warning
level, and that no warnings are permitted. Then, as programmers
run into warnings that aren't practical to avoid, you introduce
exceptions, either on a one time basis (the code does something
special which requires a normally dangerous construct), or
generally (the compiler is getting in a tissy about nothing).
and playing around with the warning level, I've noticed that
compiling with /W3 I get warnings that with /W4 are shown as
remarks, e.g.:
The compilers I use don't distinguish.
warning #177: variable "Foo" was declared but never referenced
...is displayed as a "remark #177" with /W4. That doesn't fit the
definitions in Intel's help page. My questions are:
1. Why did the warning turn into a remark, is this a bug?
For any specific warning, you'll have to ask the compiler
vendor.
If not, what is the intention behind this behaviour? This
doesn't include ALL warnings, e.g.
warning #504: initial value of reference to non-const must be an
lvalue
remains a warning with /W4.
That *isn't* a warning, or at least shouldn't be. That is an
error, and conformant compilers won't compile such code.
2. How come issues of conversion from "double" to "float" are
displayed only as remarks with w4? Usually they are w3 with other
compilers...?
The compilers I've seen don't usually say anything about
narrowing conversions. There are historical reasons which mean
that most such warnings are irrelevant, and rather than flood
the output with irrelevant warnings, they don't worry about it.
In many ways, it's a shame, but we can't change history.
3. Can remarks be eliminated altogether, and what is the best
way (in your opinion) to go with remarks/warnings?
Again, most compilers don't distinguish. In the end: ideally,
you should strive for no output from the compiler, but
practically, you're going to have to evaluate, and allow some.
The decision should be based on your requirements, not any
categorization by the compiler, however.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Jun 26 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.