Bug 32734 - bogus "template with C linkage" from erroneous #line directives
Summary: bogus "template with C linkage" from erroneous #line directives
Status: RESOLVED WORKSFORME
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-12 01:11 UTC by Alan Pita
Modified: 2007-11-06 23:32 UTC (History)
3 users (show)

See Also:
Host: Mac OS 10.4
Target: native
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
simple C++ input file that shows the problem (208 bytes, text/plain)
2007-07-12 01:13 UTC, Alan Pita
Details
minor tweaking of c++ preprocessor output which fixes the problem (206 bytes, text/plain)
2007-07-12 01:14 UTC, Alan Pita
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Pita 2007-07-12 01:11:46 UTC
While attempting to compile Xerces 2.7 on MacOS, I discovered what I think
is a bug in gcc, which I'm using for all phases of build. The c++ preprocessor
is emitting line number statements which have an inconsistent number of
arguments after the file name, e.g.:

# 1 "/usr/include/xercesc/util/XMLEnumerator.hpp" 1 3 4

vs.

# 25 "/usr/include/xercesc/util/XMLEnumerator.hpp" 3 4

and, in the former case (with the extra number), it seems to introduce some
compiler behavior where a subsequent template class definition will be
rejected with the misguiding error message "template with C linkage".

I have whittled the problem down to a single preprocessed source file that exhibits this 
problem - will try to attach it once I can figure out Bugzilla's UI.

Thanks for your help and advice!

Alan
Comment 1 Alan Pita 2007-07-12 01:13:29 UTC
Created attachment 13892 [details]
simple C++ input file that shows the problem
Comment 2 Alan Pita 2007-07-12 01:14:05 UTC
Created attachment 13893 [details]
minor tweaking of c++ preprocessor output which fixes the problem
Comment 3 Alan Pita 2007-07-12 01:14:39 UTC
zeus:~/projects/xerces-c-src_2_7_0 pitaman$ gcc fails.cpp
/usr/include/xercesc/util/XMLEnumerator.hpp:2: error: template with C linkage
zeus:~/projects/xerces-c-src_2_7_0 pitaman$ gcc succeeds.cpp
/usr/bin/ld: Undefined symbols:
_main
collect2: ld returned 1 exit status
Comment 4 Andrew Pinski 2007-07-12 01:25:17 UTC
How did /usr/include/xercesc come to exist?  Was it there before compiling Xerces or did it use that as the default path for install?
Comment 5 Alan Pita 2007-07-12 20:55:07 UTC
Subject: Re:  bogus "template with C linkage" from erroneous #line directives

That directory did not exist - once I had built Xerces I manually  
copied the files there.

Alan

On Jul 11, 2007, at 8:25 PM, pinskia at gcc dot gnu dot org wrote:

>
>
> ------- Comment #4 from pinskia at gcc dot gnu dot org  2007-07-12  
> 01:25 -------
> How did /usr/include/xercesc come to exist?  Was it there before  
> compiling
> Xerces or did it use that as the default path for install?
>
>
> -- 
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32734
>
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.

Comment 6 Andrew Pinski 2007-07-12 21:20:57 UTC
Don't copy into /usr/include, use /usr/local/include instead.

Anyways the underlaying issue has been fixed for 4.2.0.
Comment 7 Alan Pita 2007-07-12 21:56:20 UTC
Subject: Re:  bogus "template with C linkage" from erroneous #line directives

Good to know it. Thanks for the response.

Alan

On Jul 12, 2007, at 4:20 PM, pinskia at gcc dot gnu dot org wrote:

>
>
> ------- Comment #6 from pinskia at gcc dot gnu dot org  2007-07-12  
> 21:20 -------
> Don't copy into /usr/include, use /usr/local/include instead.
>
> Anyways the underlaying issue has been fixed for 4.2.0.
>
>
> -- 
>
> pinskia at gcc dot gnu dot org changed:
>
>            What    |Removed                     |Added
> ---------------------------------------------------------------------- 
> ------
>              Status|UNCONFIRMED                 |RESOLVED
>          Resolution|                            |WORKSFORME
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32734
>
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.

Comment 8 Eric Goff 2007-11-06 23:32:17 UTC
This is clearly not fixed, even in 4.2.2.

In file included from fails.cpp:2:
/usr/include/xercesc/util/XMLEnumerator.hpp:2: error: template with C linkage