Bug 84583 - -fdirectives-only does not handle CRLF properly
Summary: -fdirectives-only does not handle CRLF properly
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: preprocessor (show other bugs)
Version: 12.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-27 08:33 UTC by Boris Kolpackov
Modified: 2023-01-24 08:52 UTC (History)
1 user (show)

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


Attachments
reproducing source code (2.91 KB, application/gzip)
2018-02-27 08:33 UTC, Boris Kolpackov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Boris Kolpackov 2018-02-27 08:33:38 UTC
Created attachment 43515 [details]
reproducing source code

The attached archive contains foo.c (as well as foo.p and foo.i, for reference) that if preprocessed with -fdirectives-only on Windows (for example, using the MinGW build of GCC) produces incorrect result:

gcc.exe -E -fdirectives-only -o foo.p foo.c
gcc.exe -E -fpreprocessed -fdirectives-only -x c foo.p >foo.i

foo.c:7:16: warning: missing terminating " character
foo.c:9:30: warning: missing terminating " character

It appears that in the first invocation GCC replaces each LF character with the CRLF sequence thus ending up with CRCRLF sequences.

Will be happy to test a patch.
Comment 1 Boris Kolpackov 2021-07-29 07:04:59 UTC
Still being bitten by this with GCC 10.2. Any translation unit that uses a line continuation in a string literal triggers this bug. A typical example:

char copyright[] =
"@(#) Copyright (c) 1990 The Regents of the University of California.\n\
 All rights reserved.\n";
Comment 2 Boris Kolpackov 2023-01-24 08:52:53 UTC
Still present in GCC 12.2.0. Just hit it with SQLite 3.39.4 source code (shell.c):

shell.exe.o.i:165900:40: error: unterminated string literal