From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10183 invoked by alias); 7 Jul 2005 14:54:38 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 10143 invoked by uid 22791); 7 Jul 2005 14:54:33 -0000 Received: from bay106-f7.bay106.hotmail.com (HELO hotmail.com) (65.54.161.17) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Thu, 07 Jul 2005 14:54:33 +0000 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Thu, 7 Jul 2005 07:53:30 -0700 Message-ID: Received: from 65.54.161.200 by by106fd.bay106.hotmail.msn.com with HTTP; Thu, 07 Jul 2005 14:53:30 GMT X-Originating-Email: [neo_in_matrix@msn.com] X-Sender: neo_in_matrix@msn.com In-Reply-To: <42CCB23C.4080108@kangaroologic.com> From: "Neo Anderson" To: gcc-help@gcc.gnu.org Bcc: Subject: Re: What is the purpose of 'warning: no newline at end of file'? Date: Thu, 07 Jul 2005 14:54:00 -0000 Mime-Version: 1.0 Content-Type: text/plain; format=flowed X-SW-Source: 2005-07/txt/msg00077.txt.bz2 Thanks, that makes things much clearer for me. ----Original Message Follows---- From: Jonathan Turkanis 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 22:40:28 -0600 [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 > 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 > > > >