http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46814
Summary: Off by one in "In file included from" with
already-preprocessed source
Product: gcc
Version: 4.4.4
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: preprocessor
AssignedTo: [email protected]
ReportedBy: [email protected]
linemap_print_containing_files is reporting invalid line numbers in source that
has already been run through the preprocessor. Tested on 4.2.1, 4.4.1 and
4.4.4, do not immediately have access to higher versions but will check.
This bug is also manifested via -save-temps (!).
Compilers tested:
gcc version 4.4.4 (Gentoo 4.4.4-r1 p1.0, pie-0.4.5), Target: x86_64-linux-gnu
gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9), Target: x86_64-linux-gnu
gcc version 4.2.1 (Apple Inc. build 5664), Target: i686-apple-darwin10
gcc version 4.2.1 (Apple Inc. build 5664), Target: arm-apple-darwin10
It is best illustrated by the following:
x.cc
----
#include "badheader.h"
int main() { return 42; }
badheader.h
-----------
x;
---
gcc -c -o o/x.o x.cc
In file included from x.cc:1:
badheader.h:1: error: expected constructor, destructor, or type conversion
before ‘;’ token
gcc -E -o o/x.ii x.cc
gcc -c -o o/xii.o o/x.ii
In file included from x.cc:2:
badheader.h:1: error: expected constructor, destructor, or type conversion
before ‘;’ token
-v -save-temps:
$ gcc -v -save-temps -o x x.cc
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc/gcc-5664~38/src/configure --disable-checking
--enable-werror --prefix=/usr --mandir=/share/man
--enable-languages=c,objc,c++,obj-c++
--program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib
--build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10-
--host=x86_64-apple-darwin10 --target=i686-apple-darwin10
--with-gxx-include-dir=/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5664)
/usr/libexec/gcc/i686-apple-darwin10/4.2.1/cc1plus -E -quiet -v -imultilib
x86_64 -D__DYNAMIC__ x.cc -fPIC -mmacosx-version-min=10.6.5 -m64 -mtune=core2
-fpch-preprocess -D__private_extern__=extern -o x.ii
ignoring nonexistent directory
"/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../../../i686-apple-darwin10/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/4.2.1
/usr/include/c++/4.2.1/i686-apple-darwin10/x86_64
/usr/include/c++/4.2.1/backward
/usr/local/include
/usr/lib/gcc/i686-apple-darwin10/4.2.1/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
/usr/libexec/gcc/i686-apple-darwin10/4.2.1/cc1plus -fpreprocessed x.ii -fPIC
-quiet -dumpbase x.cc -mmacosx-version-min=10.6.5 -m64 -mtune=core2 -auxbase x
-version -D__private_extern__=extern -o x.s
GNU C++ version 4.2.1 (Apple Inc. build 5664) (i686-apple-darwin10)
compiled by GNU C version 4.2.1 (Apple Inc. build 5664).
GGC heuristics: --param ggc-min-expand=150 --param ggc-min-heapsize=65536
Compiler executable checksum: b2d9fc2676bcbc4fe5c6f07f902dbb00
In file included from x.cc:2:
badheader.h:1: error: expected constructor, destructor, or type conversion
before ‘;’ token
The current preprocessed output for x.cc is as follows:
# 1 "x.cc"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "x.cc"
# 1 "badheader.h" 1
x;
# 2 "x.cc" 2
int main() { return 42; }