http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53930
Bug #: 53930 Summary: bug in linker Classification: Unclassified Product: gcc Version: 4.5.3 Status: UNCONFIRMED Severity: critical Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: bespalo...@gmail.com Created attachment 27777 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27777 archive with source files I encounter it in number of versions, on number of platforms: 4.5.3 on gentoo, 4.6.2 on cygwin. The problem's description: sequence of files listed in g++ as input file - does matter. I have 2 cpps (file1 and file2), each has own implementation of struct A. In main.cpp I call test1() from file1.cpp, which has following implementation: void test1() { A a; } The problem is that if I have following build command: g++ -o test -I. main.cpp file2.cpp file1.cpp -Wall -Wextra (take attention: file2.cpp precedes file1.cpp) - test1 actually gets A implementation from test2.cpp. If I change build command in way when file1.cpp precedes file2.cpp, test1 gets own (right) implementation of A: g++ -o test -I. main.cpp file1.cpp file2.cpp -Wall -Wextra This is wrong, since order of cpp files in the input list of g++ should not change the resulting code. I've attached the sample. There is the following commands for build: g++ -o test1 -I. main.cpp file2.cpp file1.cpp -Wall -Wextra g++ -o test2 -I. main.cpp file1.cpp file2.cpp -Wall -Wextra Although the files are same, test1 and test2 has different behavior. platform: uname -a Linux SONY 3.3.8-gentoo #1 SMP Tue Jul 10 06:15:45 MSK 2012 x86_64 Intel(R) Pentium(R) CPU B940 @ 2.00GHz GenuineIntel GNU/Linux gcc --version gcc (Gentoo 4.5.3-r2 p1.1, pie-0.4.7) 4.5.3 Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Regards, Dmitry.