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
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.
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.
(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"
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.
(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.
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.
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.
(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