Bug 25940 - multiple definitions of extern "C" functions
Summary: multiple definitions of extern "C" functions
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid, assemble-failure
: 63769 87179 (view as bug list)
Depends on: 13699
Blocks:
  Show dependency treegraph
 
Reported: 2006-01-24 08:31 UTC by Wolfgang Roehrl
Modified: 2024-07-19 22:18 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 3.4.5, 4.0.2, 4.1.0, 4.2.0
Last reconfirmed: 2021-12-04 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Roehrl 2006-01-24 08:31:28 UTC
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
Comment 1 Andrew Pinski 2006-01-24 12:40:37 UTC
Confirmed.
Comment 2 Richard Biener 2006-01-25 10:52:58 UTC
Shorter testcase:

namespace N1 {
  extern "C" int func (int);
  int func (int) {}
};
namespace N2 {
  extern "C" int func (int);
  int func (int) {}
};

not a regression from anything.  Not dependent on weird cross configuration.
Comment 3 Andrew Pinski 2006-02-01 18:15:57 UTC
Related closely to PR 13699.
Comment 4 Andrew Pinski 2014-11-07 00:15:13 UTC
*** Bug 63769 has been marked as a duplicate of this bug. ***
Comment 5 Andrew Pinski 2018-09-01 00:22:46 UTC
*** Bug 87179 has been marked as a duplicate of this bug. ***