This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: backslash whitespace newline
On Tue, Oct 25, 2005 at 08:22:12PM -0400, Andrew Pinski wrote:
> Why not get other compilers to change to what GCC does? Why does GCC
> have to follow what other compilers do, maybe other compilers
> would be in the best interest of following what GCC does.
The problem, I think, is that the behavior of both GCC *and* the
other compilers does not serve the users.
The reason is that there simply isn't any reason why a user would
use a backslash to continue a C++ comment on purpose, and plenty of
reason why she might do it by accident.
There appear to be five relevant cases; the backslash-newline (or
whitespace/backslash/newline) can be in
1) a C++ comment
2) a C comment
3) a string literal
4) a preprocessor directive
5) somewhere else.
For cases 2 and 5, the behavior doesn't matter. For case 3, the
continuation is unlikely to be accidental, and the user is, I think,
less likely to leave a stray slash in case 4.
But case 1 is the nasty one, as users think they can put anything
in a comment. A backslash at the end is likely to be an accident,
since just starting the next line with a // is easy enough.
So, I think that a trailing backslash at the end of a C++ comment
(followed or not by whitespace) should be warned about. I think
Apple's customers would want this warning too, since many of them
will also be interested in compiling for other systems, and there
is a lot of gcc 3.x out there. Best to use warnings to get rid
of the problematic code.