Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-12-15 19:12:33

"Paul A. Bristow" <boost_at_[hidden]> writes:

Paul, the formatting of your post makes it hard to read and hard to
participate in. To begin with, you begin by addressing a sentence to
"you" with no indication of who you're responding to. The fact that
the original post was quoted completely at the bottom of your message
was lost on me until I began to compose this reply. Next, you say
that someone was "insisting" on warning free code, but I had no memory
of such a post. Finally, a little judicious indentation goes a long
way. For example:


| It worries me somewhat to see too many warnings disabled. It begins to
| nullify the benefits of using a higher warning level.
| -Bruce Johnston
| Simba Technologies

I fear you are raising the bar excessively to _insist_ on warning free
code. But there is growing support

  1 to reduce the number of warnings where possible, and

  2 to disable warnings primarily to document belief that the warning
    is not significant.

Would it be useful to draw up a list of warnings that

  1 we always ignore,

  2 those that we never ignore (means that the code needs some
    improvement), and

  3 those we should try to avoid (by addition to code), and

  4 to agree a 'Boost Standard' way to disable warnings.

To start a discussion, I have extracted below some common warnings info from
MSVC 7.1 :

1 Compiler Warning (level 1) C4276'function' : no prototype provided; assumed
  no parameters

  When you take the address of a function with the __stdcall calling
  convention, you must give a prototype so the compiler can create
  the function's decorated name. Since function has no prototype,
  the compiler, when creating the decorated name, assumes the
  function has no parameters.

  (No example given).

  (I presume the original C4267 is a typo for C4276?)

  Suggestions on waht to do about this?

2 Compiler Warning (level 4) C4127 conditional expression is constant

  The controlling expression of an if statement or while loop
  evaluates to a constant. The code in the body of the if statement
  or while loop always executes or never executes. The following
  sample generates C4127:

    // C4127.cpp
    // compile with: /W4
    int main() {
       if (1 == 1) { // C4127, constant expression

  This is very common and I believe for Boost code it should always be ignored.
  It has no run-time cost? (Or has it in debug?)


Dave Abrahams
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at