Bug 41748 - Adjust documentation to reflect new (afrer rev. 152599) cpp behavior
Summary: Adjust documentation to reflect new (afrer rev. 152599) cpp behavior
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: preprocessor (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-19 07:07 UTC by Dmitry Gorbachev
Modified: 2011-01-27 08:35 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target:
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Gorbachev 2009-10-19 07:07:41 UTC
This is a testcase (a space before a backslash or after a newline, and two pairs of quotes (or no quotes at all), are important):

"hello," \
"world"

In GCC 4.5.0 20091015, preprocessor produces this:

# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "<stdin>"
"hello,"
 "world"

whereas older GCC versions give this:

# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "<stdin>"
"hello," "world"

Such a new behavior seems to be in contradiction with what the documentation says: "the backslash is removed and the following line is joined with the current one."
Comment 1 Jakub Jelinek 2009-10-19 08:13:03 UTC
The lines are joined into a logical line, that's what the C standard requires.  But where do you see requirement that everything on one logical line has to appear on the line in preprocessed output?  The reason it is emitted on the next line is to give the second string literal token proper location.  The tokens are separate and a compiler compiles both "foo" "bar" and
"foo"
"bar"
the same (as it doesn't record the line numbers for the string literals at all).
See PR41445 for why this change has been made.

If you care about this because you use the preprocessed output for something else, consider using -P option.  That says you don't care about token locations.
Comment 2 Dmitry Gorbachev 2009-10-19 13:17:49 UTC
Ok, thanks for the clarification.

I believe this should be documented.
Comment 3 Dmitry Gorbachev 2011-01-27 08:35:26 UTC
Documented on 'Frequently Asked Questions' wiki page: <http://gcc.gnu.org/wiki/FAQ#cpp_continuation_discarded>.