preprocessor bug(?)

Dale Johannesen dalej@apple.com
Thu Nov 7 17:26:00 GMT 2002


On Thursday, November 7, 2002, at 04:30  PM, Zack Weinberg wrote:

> On Thu, Nov 07, 2002 at 04:19:31PM -0800, Dale Johannesen wrote:
>> One of our users just did this:
>>
>> // comment, space character follows the backslash:\
>> main() {
>> }
>>
>> gcc ignores the space character, which causes the comment to eat the
>> next line.
>> That's wrong, isn't it?
>
> No, that's an intentional feature.  From the manual:
>
>   3. Continued lines are merged into one long line.
>        ....
>      If there is white space between a backslash and the end of a line,
>      that is still a continued line.  However, as this is usually the
>      result of an editing mistake, and many compilers will not accept
>      it as a continued line, GCC will warn you about it.
>
> Note especially the last paragraph.  The user did get a warning,
> didn't they?

No.

I understand this is a feature in the case where the \<space> is not 
inside
a comment, and I think it's a useful one.  But I believe the behavior 
described
above violates the standards in this case.  Translation phase 2 is not 
supposed
to replace \<space>, and the // comment eats all characters (not 
tokens) up
to the end of the line.  It looks to me like the program above is 
standard-conforming
and gcc miscompiles it.



More information about the Gcc mailing list