public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Turkanis <technews@kangaroologic.com>
To: gcc-help@gcc.gnu.org
Subject: Re: What is the purpose of 'warning: no newline at end of file'?
Date: Thu, 07 Jul 2005 04:39:00 -0000	[thread overview]
Message-ID: <42CCB23C.4080108@kangaroologic.com> (raw)
In-Reply-To: <BAY106-F193FD8531E7F331E4E3008BDD80@phx.gbl>

[Sorry Neo, I think I sent you personal email accidentally]

Neo Anderson wrote:

 > So, what is the purpose of this warning? What possible 'damages' does this 
warning protect against?


I believe this language was added to the standard because at the time some 
systems were not able to handle files properly if they didn't end in a newline. 
This wording made it possible to provide conforming C++ implementations for 
those platforms.

I'm not sure if there still are any such systems, but because the standard has 
given implementations to freedom to do whatever they want (that's what undefined 
behavior means) if you tell them to process a file not ending in a newline, be 
warned that if you try to compile your code on another system, the compiler may 
refuse. I know, for example, that Comeau in strict mode won't compile it. For 
that matter, neither will gcc with -pedantic-errors.

Jonathan

 > And, what is the 'the behavior'?
 >
 > ----Original Message Follows----
 > From: Jonathan Turkanis <technews@kangaroologic.com>
 > To: gcc-help@gcc.gnu.org
 > Subject: Re: What is the purpose of 'warning: no newline at end of file'?
 > Date: Wed, 06 Jul 2005 21:41:20 -0600
 >
 > Neo Anderson wrote:
 >
 >> I don't even think it's a problem. Why do I need (or better have) a line ending?
 >
 >
 >
 > The C++ standard says: If a source file that is not empty does not end in a 
newline character, or ends in a newline character immediately preceded by a 
backslash character, the behavior is undefined. (2.1/1)
 >
 > Jonathan
 >
 >
 >
 >



  parent reply	other threads:[~2005-07-07  4:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-07  3:34 Neo Anderson
2005-07-07  3:40 ` Jonathan Turkanis
2005-07-07  3:44   ` corey taylor
2005-07-07  4:16   ` Neo Anderson
2005-07-07  4:32     ` Ian Lance Taylor
2005-07-07  4:39     ` Jonathan Turkanis [this message]
2005-07-07 14:54       ` Neo Anderson
2005-07-07 11:35     ` Eljay Love-Jensen
2005-07-07 14:41       ` Neo Anderson
2005-07-07 15:23         ` Eljay Love-Jensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42CCB23C.4080108@kangaroologic.com \
    --to=technews@kangaroologic.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).