continued lines not always merged into one long line

Bug #1075243 reported by J. Lewis Muir
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc-defaults (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

The GCC C 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. It contains the following three lines (the first two lines end with a backslash):

struct {\
  int x;\
};

Running gcc with the -E option produces the following:

$ gcc -E continued-line-test.c
# 1 "continued-line-test.c"
# 1 "<built-in>"
# 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. Of course, this is a simple example, but I have software that depends on correct line continuation processing in order to build.

The GCC documentation (http://gcc.gnu.org/onlinedocs/gcc-4.6.3/cpp/Initial-processing.html#Initial-processing) says:

"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.)"

The observed behavior is inconsistent with this statement from the documentation.

What I expected to see is the following:

$ gcc -E continued-line-test.c
# 1 "continued-line-test.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "continued-line-test.c"
struct { int x;};

Here's my Ubuntu version information:

$ lsb_release -rd
Description: Ubuntu 12.04.1 LTS
Release: 12.04

And here's the package version information:

$ apt-cache policy gcc-4.6
gcc-4.6:
  Installed: 4.6.3-1ubuntu5
  Candidate: 4.6.3-1ubuntu5
  Version table:
 *** 4.6.3-1ubuntu5 0
        500 http://us.archive.ubuntu.com/ubuntu/ precise/main i386 Packages
        100 /var/lib/dpkg/status

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: gcc 4:4.6.3-1ubuntu5
ProcVersionSignature: Ubuntu 3.2.0-32.51-generic 3.2.30
Uname: Linux 3.2.0-32-generic i686
NonfreeKernelModules: prl_fs_freeze prl_fs prl_tg prl_eth
ApportVersion: 2.0.1-0ubuntu14
Architecture: i386
Date: Mon Nov 5 10:29:32 2012
InstallationMedia: Ubuntu 10.04.1 LTS "Lucid Lynx" - Release i386 (20100816.1)
ProcEnviron:
 TERM=xterm
 PATH=(custom, user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: gcc-defaults
UpgradeStatus: Upgraded to precise on 2012-05-03 (186 days ago)

Revision history for this message
J. Lewis Muir (jlmuir) wrote :
Revision history for this message
J. Lewis Muir (jlmuir) wrote :

I'm also able to reproduce this problem in GCC 4.7.2. I've submitted a bug report to the GCC project (bug #55242). It can be viewed at <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55242>.

Revision history for this message
J. Lewis Muir (jlmuir) wrote :

According to the comment made at 2012-11-09 20:23:47 UTC by Dmitry Gorbachev on the GCC bug report, this behavior is a feature, not a bug. So, sorry for the trouble; this Ubuntu bug report can be closed.

Matthias Klose (doko)
Changed in gcc-defaults (Ubuntu):
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.