Compiler warnings vs remarks mystery

Discussion in 'C++' started by gil@waves.com, Jun 25, 2007.

  1. Guest

    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, 2007
    #1
    1. Advertising

  2. 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
     
    Victor Bazarov, Jun 25, 2007
    #2
    1. Advertising

  3. Marcus Kwok Guest

    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
     
    Marcus Kwok, Jun 25, 2007
    #3
  4. James Kanze Guest

    On Jun 25, 2:15 pm, 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:
    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
     
    James Kanze, Jun 26, 2007
    #4
  5. Pete Becker Guest

    James Kanze wrote:
    >
    >> 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.
    >


    Conformant compilers will issue a diagnostic. That's all that's required
    by the standard. And the meaning of "diagnostic" is up to the
    implementor. Every compiler I know of documents warnings as a form of
    diagnostic.

    --

    -- Pete
    Roundhouse Consulting, Ltd. (www.versatilecoding.com)
    Author of "The Standard C++ Library Extensions: a Tutorial and
    Reference." (www.petebecker.com/tr1book)
     
    Pete Becker, Jun 26, 2007
    #5
  6. James Kanze Guest

    On Jun 26, 1:50 pm, Pete Becker <> wrote:
    > James Kanze wrote:


    > >> 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.


    > Conformant compilers will issue a diagnostic. That's all that's required
    > by the standard. And the meaning of "diagnostic" is up to the
    > implementor. Every compiler I know of documents warnings as a form of
    > diagnostic.


    That's true. Most compilers "document" what is a diagnostic in
    the sense of the standard as "anything the compiler happens to
    output". (They don't use exactly those words, but that's the
    real meaning.)

    --
    James Kanze (Gabi Software) email:
    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
     
    James Kanze, Jun 26, 2007
    #6
  7. Pete Becker wrote:
    > Conformant compilers will issue a diagnostic. That's all that's required
    > by the standard. And the meaning of "diagnostic" is up to the
    > implementor. Every compiler I know of documents warnings as a form of
    > diagnostic.


    That's a bit inexact. A diagnostic is always an output message. What
    is up to the implementation is choosing and documenting which of its
    output messages are diagnostics.


    --
    \|||/ Gennaro Prota - For hire
    (o o) https://sourceforge.net/projects/breeze/
    --ooO-(_)-Ooo----- (to mail: name . surname / yaho ! com)
     
    Gennaro Prota, Jun 28, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MattB

    remarks in Intellisense

    MattB, Sep 7, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    2,205
    Greg Burns
    Sep 7, 2004
  2. Michael S. Scherotter

    <remarks/> in proxy classes

    Michael S. Scherotter, Feb 15, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    131
    Michael S. Scherotter
    Feb 15, 2006
  3. Onideus Mad Hatter

    Hrmmm...Suggestions, Ideas, Pointless Remarks?

    Onideus Mad Hatter, Jul 3, 2005, in forum: Javascript
    Replies:
    14
    Views:
    188
    Thomas 'PointedEars' Lahn
    Jul 16, 2005
  4. Rainer Weikusat

    Two remarks about the Perl object model

    Rainer Weikusat, Aug 22, 2012, in forum: Perl Misc
    Replies:
    0
    Views:
    406
    Rainer Weikusat
    Aug 22, 2012
  5. Rainer Weikusat

    some random remarks about Moose::Manual::Concepts

    Rainer Weikusat, Mar 2, 2013, in forum: Perl Misc
    Replies:
    12
    Views:
    371
    Steve May
    Mar 7, 2013
Loading...

Share This Page