[Bug c++/25940] New: multiple definitions of extern "C" functions

wolfgang dot roehrl at gi-de dot com gcc-bugzilla@gcc.gnu.org
Tue Jan 24 08:31:00 GMT 2006


Dear all,

I would like to post a bug report for the GNU C/C++ compiler 3.3-e500.

We use the compiler to generate code for a PowerPC processor.

Used invokation line for the GNU C++ compiler:

ccppc -c -x c++ -ansi -Wall -Werror -mcpu=8540 -fverbose-asm -mbig
      -fmerge-templates -mmultiple -mno-string -mstrict-align -O3
      -fno-exceptions -fno-rtti -fno-builtin-printf
      -I<different include paths>
      -D<differen #define's>
      X.CPP -oX.O


// file X.CPP

namespace N1 {

extern "C" int func (int);

}


namespace N2 {

extern "C" int func (int);

}


namespace N3 {

extern "C" int func (int);

int func (int i) { return i * 2; }        // <--- definition of func()

}


int N1::func (int i) { return i / 2; }    // <--- func() already defined!


namespace N2 {

int func (int i) { return i + 2; }        // <--- func() already defined!

}


The compiler accepts this program and generates illegal assembler code:
the label 'func' is defined three times as a global symbol.

According to 7.5/6 the compiler should reject the program since func() is
defined three times (see also 7.3.4/4).


Kind regards
W. Roehrl


-- 
           Summary: multiple definitions of extern "C" functions
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wolfgang dot roehrl at gi-de dot com
 GCC build triplet: sparc-sun-solaris2.5.1
  GCC host triplet: i386-pc-mingw32
GCC target triplet: powerpc-wrs-vxworks


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



More information about the Gcc-bugs mailing list