http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55242



             Bug #: 55242

           Summary: continued lines not always merged into one long line

    Classification: Unclassified

           Product: gcc

           Version: unknown

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: preprocessor

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: jlm...@anl.gov





Created attachment 28639

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28639

Small source file demonstrating bug



The preprocessor sometimes incorrectly handles a line continuation by not

joining a following line with the current line.



Attached is a simple C file called continued-line-test.c that demonstrates the

problem.  It contains the following three lines (the first two lines end with a

backslash):



struct {\

  int x;\

};



Running gcc on this file with the -E option produces the following:



$ gcc -E continued-line-test.c 

# 1 "continued-line-test.c"

# 1 "<command-line>"

# 1 "continued-line-test.c"

struct {

  int x;};



As you can see, even though the first line in continued-line-test.c ended with

a backslash, the second line was not joined with the first line.



The preprocessor documentation

(http://gcc.gnu.org/onlinedocs/gcc-4.7.2/cpp/Initial-processing.html#Initial-processing)

says:



"Continued lines are merged into one long line.



"A continued line is a line which ends with a backslash, `\'.  The backslash is

removed and the following line is joined with the current one.  No space is

inserted, so you may split a line anywhere, even in the middle of a word.  (It

is generally more readable to split lines only at white space.)"



What I expected to see is the following:



$ gcc -E continued-line-test.c

# 1 "continued-line-test.c"

# 1 "<command-line>"

# 1 "continued-line-test.c"

struct { int x;};



Here's the version information from GCC:



$ gcc -v

Using built-in specs.

COLLECT_GCC=/opt3/bin/gcc

COLLECT_LTO_WRAPPER=/opt3/libexec/gcc/x86_64-apple-darwin12/4.7.2/lto-wrapper

Target: x86_64-apple-darwin12

Configured with: ../gcc-4.7.2/configure --prefix=/opt3

--build=x86_64-apple-darwin12

--enable-languages=c,c++,objc,obj-c++,lto,fortran,java --libdir=/opt3/lib/gcc47

--includedir=/opt3/include/gcc47 --infodir=/opt3/share/info

--mandir=/opt3/share/man --datarootdir=/opt3/share/gcc-4.7

--with-libiconv-prefix=/opt3 --with-local-prefix=/opt3 --with-system-zlib

--disable-nls --program-suffix=-mp-4.7

--with-gxx-include-dir=/opt3/include/gcc47/c++/ --with-gmp=/opt3

--with-mpfr=/opt3 --with-mpc=/opt3 --with-ppl=/opt3 --with-cloog=/opt3

--enable-cloog-backend=isl --disable-cloog-version-check

--enable-stage1-checking --disable-multilib --enable-lto

--enable-libstdcxx-time --with-as=/opt3/bin/as --with-ld=/opt3/bin/ld

--with-ar=/opt3/bin/ar --with-bugurl=https://trac.macports.org/newticket

--disable-ppl-version-check --with-pkgversion='MacPorts gcc47 4.7.2_2'

Thread model: posix

gcc version 4.7.2 (MacPorts gcc47 4.7.2_2) 



I'm also able to reproduced this problem with GCC 4.6.3 on Ubuntu Linux 12.04.1

LTS.

Reply via email to