473,395 Members | 1,689 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,395 software developers and data experts.

Compiler warnings vs remarks mystery

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
3 3171
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: dis | last post by:
I've been going through my code and clearing away some of the compiler warnings that i'm generating and i've come across areas where i cast pointers to integer values. The Visual Studio compiler...
20
by: News | last post by:
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...
8
by: Charlie Zender | last post by:
Hi, First, this may be a GCC or Linux-specific problem, I'm not sure. I am unable to compile a large body of code with extremely pedantic compile time checks activate, so that warnings cause...
1
by: george doubleu | last post by:
hi, i'm using "gcc version 3.3.3 (Debian)" to compile the program pasted below. I get the two warnings you can see in the remarks. The second warning is perfectly OK for me, but the first one I...
43
by: Anitha | last post by:
Hi I observed something while coding the other day: if I declare a character array as char s, and try to use it as any other character array..it works perfectly fine most of the times. It...
2
by: Samuel | last post by:
Imagine you have the following code: try { ... } catch (ThreadAbortException eThread) { if (WorkStopped != null) WorkStopped(this, EventArgs.Empty) }
5
by: rawCoder | last post by:
Hi All, In Visual Basic .NET , your function definition might requirre you to return a value but (accidently/intentionally) you dont put any 'return value' in the function. In this case VB...
11
by: Charles Sullivan | last post by:
I have a number of functions, e.g.: int funct1( int arg1, int arg2, int arg3 ); int funct2( int arg1, int arg2, int arg3 ); int funct3( int arg1, int arg2, int arg3 ); that are called via...
3
by: Peted | last post by:
Hi Im using vs2008 c# 3.0 and am going through some other person(s) code to clean up compiler warnings that are bieng produced. I have this code (at bottom) where a delegate/event is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.