This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: escaped newline handling

On Thu, Feb 21, 2002 at 09:06:52AM +0100, Jan Beulich wrote:

> ... in the case
> of a single line comment, the is different. Not only is the original
> warning being suppressed in this case (and a different warning being
> issued), but in a single line comment that uses the backslash to, say,
> illustrate something (as in
> // comment  \/
> // using    |
> // some     |
> // graphics /\ 
> void test() {
> }
> ) code that is standard-conforming will break (in the example, the
> first token seen following the comments will be the closing brace).

"Standard conforming" is ill-defined.  That is not, however, a
_strictly_ conforming program.  It depends on implementation dependent
behavior, namely the conversion performed by translation phase 1.  C99 paragraph 1:

   1. Physical source file multibyte characters are mapped, in an
      implementation-defined manner, to the source character set
      (introducing new-line characters for end-of-line indicators) if
      necessary.  Trigraph sequences are replaced by corresponding
      single-character internal representations.

Please note the phrase "in an implementation-defined manner."  GCC
defines the transformation to ignore all trailing whitespace at the
end of a line (but a warning issues when this affects the meaning of
the program).  This is hardly an exotic definition.  On a system with
record-format text files, it may be flat impossible to have trailing
whitespace on a line.

Furthermore, your scenario is both unusual, and easily remedied, by
putting some characters at the right edge of the comment block:

// comment   \ /  //
// using      |   //
// some       |   //
// graphics  / \  //

The situation where trailing whitespace is accidentally introduced and
causes an error cascade is far more common.  We feel it is more
important for GCC to cater to the common situation.

GCC's behavior will not change.  (However, I would consider a patch to
silence both this warning and the warning about a \-newline at the end
of a line comment, when the line which has been sucked into the //
comment is blank or consists entirely of another line comment.)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]