473,756 Members | 3,499 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3194
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 "diagnostic s" 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 objektorientier ter Datenverarbeitu ng
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
11227
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 generates this warning ... "warning C4311: 'type cast' : pointer truncation from 'void *' to 'DWORD'" The warning is generated as the pointer is apparently 64 bits long (even though a quick sizeof() reports it to only be 4 bytes in length) and...
20
2729
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 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...
8
5165
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 errors. With GCC 3.3.1, I do this with gcc -I/usr/local/include -g -O2 -std=c99 -pedantic -pedantic -D_BSD_SOURCE -Wall -Wunused -W -Wmissing-prototypes -Wconversion
1
2118
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 don't understand. Isn't the "const int *" construct in the signature of func1 a hint for the user, that func1 doesn't modify **arg? Why then is it dangerous to pass an alterable argmument?
43
2737
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 holds strings of any length. I guess what is happening here is that this array initially holds only '\0' and hence is of length 1. But sometimes, when I tried to write some functions and do some
2
1722
by: Samuel | last post by:
Imagine you have the following code: try { ... } catch (ThreadAbortException eThread) { if (WorkStopped != null) WorkStopped(this, EventArgs.Empty) }
5
1792
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 Compiler does not generate any warning. Is there any way to make the compiler generate this and other obvious warnings, is there any switch, or still VB.NET development team assumes that
11
23240
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 pointers in a table, with the same parameters regardless of the particular function. In some of the functions, one or more of the
3
1742
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 defined and it builds ok with no errors but im trying to get rid of the
0
9273
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9872
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9841
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7244
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5141
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.