Hi! We use gcc version 3.4.4 with cygwin running on WinXP: $ gcc -v Reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs Configured with: /gcc/gcc-3.4.4/gcc-3.4.4-1/configure --verbose --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-languages=c,ada,c++,d,f77,java,objc --enable-nls --without-included-gettext --enable-version-specific-runtime-libs --without-x --enable-libgcj --disable-java-awt --with-system-zlib --enable-interpreter --disable-libgcj-debug --enable-threads=posix --enable-java-gc=boehm --disable-win32-registry --enable-sjlj-exceptions --enable-hash-synchronization --enable-libstdcxx-debug : (reconfigured) Thread model: posix gcc version 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)
We want to preprocess our C-sources and keep the comments. Therefore, we call the preprocessor like this: gcc -E -C foo.c For a comment whose lines are terminated by line-feeds, the preprocerssor works ok as the example "foo-no-cr.c" shows. $ cat -A foo-no-cr.c /*12$ 3456$ 78*/$ $ gcc -E -C foo-no-cr.c # 1 "foo-no-cr.c" # 1 "<built-in>" # 1 "<command line>" # 1 "foo-no-cr.c" /*12 3456 78*/ However, if the lines are terminated by carriage-return/line-feed pairs ("foo.c"), superfluous newlines creep into the output. $ cat -A foo.c /*12^M$ 3456^M$ 78*/^M$ $ gcc -E -C foo.c # 1 "foo.c" # 1 "<built-in>" # 1 "<command line>" # 1 "foo.c" /*12 3456 78*/ Things get even more interesting, if we use line continuation inside the comment ("foo-no-cr-backslash.c"). In the following examples, we "continue" the first line of the comment. $ cat -A foo-no-cr-backslash.c /*12\$ 3456$ 78*/$ $ gcc -E -C foo-no-cr-backslash.c # 1 "foo-no-cr-backslash.c" # 1 "<built-in>" # 1 "<command line>" # 1 "foo-no-cr-backslash.c" /*123456 6 78*/ And now the same with cr/lf-pairs ("foo-backslash.c"): $ cat -A foo-backslash.c /*12\^M$ 3456^M$ 78*/^M$ $ gcc -E -C foo-backslash.c # 1 "foo-backslash.c" # 1 "<built-in>" # 1 "<command line>" # 1 "foo-backslash.c" /*123456 56 78*/ Obviously, the preprocessor _duplicates_ the last or last and next to last character of the continuation line. This is a bug. Version 3.3.1 of the compiler does not show this bug. (It copies the comment literally, this is, does not interpret the trailing-backslash as line-continuation character.) -- Summary: '-C' option produces wrong output Product: gcc Version: 3.4.4 Status: UNCONFIRMED Severity: minor Priority: P2 Component: preprocessor AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: Christoph dot Spiel at partner dot bmw dot de CC: gcc-bugs at gcc dot gnu dot org GCC host triplet: i686-pc-cygwin GCC target triplet: i686-pc-cygwin http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23779