This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/11390] New: line directives interfere with friend linkage


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: line directives interfere with friend linkage
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rcbilson at plg dot uwaterloo dot ca
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: sparc-sun-solaris2.8
  GCC host triplet: sparc-sun-solaris2.8
GCC target triplet: sparc-sun-solaris2.8

Consider this attempt to make an extern "C" function a friend:

#define _REENTRANT

#include <errno.h>

class c
{
   int uError;
public:
    friend int *___errno();				// access: uError
};

extern "C" {
extern int *___errno()
{
}
}

(<errno.h> provides an extern "C" prototype for ___errno that matches the
definition.)

I have compiled this program on Solaris 2.6 and 8, with g++ 3.2.1 and 3.3, and
it gives me an error every time:

test.cc: In function `int* ___errno()':
test.cc:17: declaration of C function `int* ___errno()' conflicts with
test.cc:12: previous declaration `int* ___errno(...)' here

(line 12 is the friend declaration and 17 is the definition)

Strangely enough, if I copy-and-paste the contents of <errno.h> into the file,
it works fine; similarly, if I preprocess the file, strip out the "#"
line-number directives, and compile the result, it works fine.

Even more strange, if I compile the preprocessor output on a Linux system, using
the same releases of g++, it works fine even with the line-number directives.

I will attach the preprocessor output from my system.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]