Bug 40474 - gcc 4.3 no longer warns about missing newlines at end of files (regression from 4.2)
Summary: gcc 4.3 no longer warns about missing newlines at end of files (regression fr...
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.3.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-17 11:40 UTC by Romain Lerallut
Modified: 2009-06-18 18:04 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Trivial program that does *not* end with a newline (33 bytes, text/x-csrc)
2009-06-17 11:41 UTC, Romain Lerallut
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Romain Lerallut 2009-06-17 11:40:20 UTC
When compiling a C or C++ program with gcc 4.3 (and 4.4), there is no longer a warning about "no newline at end of file".

I work with people that use gcc 4.2, which emits the warning, and we use -Werror, so this is a major hindrance for us.

I'm attaching a trivial C program:

$ gcc-4.2 -o newline newline.c
newline.c:4:2: warning: no newline at end of file
$

$ gcc-4.3 -o newline newline.c
$

Versions (all from debian unstable):
gcc-4.2 --version
gcc-4.2 (GCC) 4.2.4 (Debian 4.2.4-6)
gcc-4.3 --version
gcc-4.3 (Debian 4.3.3-11) 4.3.3
gcc-4.4 --version
gcc-4.4 (Debian 4.4.0-6) 4.4.0


Regards,
Romain
Comment 1 Romain Lerallut 2009-06-17 11:41:14 UTC
Created attachment 18011 [details]
Trivial program that does *not* end with a newline

Make sure that your editor does not add silently a newline character to the file.
Comment 2 jsm-csl@polyomino.org.uk 2009-06-17 13:35:03 UTC
Subject: Re:   New: gcc 4.3 no longer warns about missing newlines
 at end of files (regression from 4.2)

On Wed, 17 Jun 2009, rlerallut at free dot fr wrote:

> When compiling a C or C++ program with gcc 4.3 (and 4.4), there is no longer a
> warning about "no newline at end of file".

This is deliberate; see bug 14331.

Comment 3 Romain Lerallut 2009-06-17 13:51:57 UTC
(In reply to comment #2)
> This is deliberate; see bug 14331.

Err... What happened to following the standard ?
"
If a source file  that  is  not  empty
      does  not end in a new-line character, or ends in a new-line char-
      acter immediately preceded by a backslash character, the  behavior
      is undefined.
" 
C++ 98, 2.1.2 "Lexical conventions"

Comment 4 jsm-csl@polyomino.org.uk 2009-06-17 13:59:11 UTC
Subject: Re:  gcc 4.3 no longer warns about missing newlines at
 end of files (regression from 4.2)

On Wed, 17 Jun 2009, rlerallut at free dot fr wrote:

> (In reply to comment #2)
> > This is deliberate; see bug 14331.
> 
> Err... What happened to following the standard ?
> "
> If a source file  that  is  not  empty
>       does  not end in a new-line character, or ends in a new-line char-
>       acter immediately preceded by a backslash character, the  behavior
>       is undefined.
> " 

Behavior being undefined means no requirement for a diagnostic, and the 
phase 1 mapping can introduce this newline in any case.

Comment 5 Romain Lerallut 2009-06-17 14:15:38 UTC
(In reply to comment #4)
> Behavior being undefined means no requirement for a diagnostic, and the 
> phase 1 mapping can introduce this newline in any case.
 
Allright, so if I develop my code with gcc 4.3, I have no way of checking for these missing newlines before sending it to my colleagues that still use gcc 4.2 ?  With Werror activated, it's quite a pain since it breaks builds on their machines.

And what happened to configuration flags ? 

Why is this change not mentioned in http://gcc.gnu.org/gcc-4.3/changes.html ?
Or here http://gcc.gnu.org/gcc-4.3/porting_to.html ? 

This is not a responsible behavior.
Comment 6 jsm-csl@polyomino.org.uk 2009-06-17 14:28:19 UTC
Subject: Re:  gcc 4.3 no longer warns about missing newlines at
 end of files (regression from 4.2)

On Wed, 17 Jun 2009, rlerallut at free dot fr wrote:

> And what happened to configuration flags ? 

Configuration flags to change details of warnings are generally a bad 
idea.

> Why is this change not mentioned in http://gcc.gnu.org/gcc-4.3/changes.html ?

That only lists significant changes, not the thousands of minor 
improvements and bug fixes for which you can search Bugzilla.  If the 
person fixing a PR doesn't feel it's significant enough to mention in the 
release notes, it won't be listed there.

> Or here http://gcc.gnu.org/gcc-4.3/porting_to.html ? 

Your concern appears to be porting from 4.3 to 4.2, and that page is about 
porting in the other direction.  We don't write documentation for 
downgrading GCC.

Comment 7 Manuel López-Ibáñez 2009-06-18 16:43:00 UTC
The warning was removed on purpose per user request, so this is WONTFIX. 

We are sorry about the inconvenience this causes to you. We humbly suggest you consider using a more modern editor, for example emacs, which will introduce a newline at the end of the file. Otherwise, your colleagues could perhaps update to the same version of GCC you are using. Developing with different versions of GCC is likely to cause some discrepancies because of fixed/new bugs.
Comment 8 Romain Lerallut 2009-06-18 18:04:49 UTC
(In reply to comment #7)
> The warning was removed on purpose per user request, so this is WONTFIX. 

Keeping an once of compatibility (or adding an option) between two minor versions would have been appreciated. Or a pragma, whatever. Not all of us have the luxury of a homogeneous development environment.

> We are sorry about the inconvenience this causes to you. We humbly suggest you
> consider using a more modern editor, for example emacs, which will introduce a
> newline at the end of the file.

So does vim [flamebait right back at you].  However many of my colleagues use visual c++ which does not have this feature (or not by default). 

> Otherwise, your colleagues could perhaps update
> to the same version of GCC you are using. Developing with different versions of
> GCC is likely to cause some discrepancies because of fixed/new bugs.

Yes. Not to mention the various behavior in floating point optimizations.  Most of our Linux-using developers use gcc 4.2 on Ubuntu's latest "long term support" release. But part of my job is to evaluate the compilers we have available (or will have in the future). I therefore routinely use gcc from 4.1 to 4.4 as well as intel's icc and visual c++.

It's already hard enough being one of the few linux people in a windows shop, you're not making my task easier.


Well, I guess you can't please everyone all the time. Wontfix it is.
 I'll patch my local copy.


Regards,
Romain