public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* Different linking behavior between g++ 4.5.2 and 4.6.1
@ 2011-11-15 17:50 Carlo Pinciroli
  2011-11-15 18:39 ` Andrew Pinski
  0 siblings, 1 reply; 4+ messages in thread
From: Carlo Pinciroli @ 2011-11-15 17:50 UTC (permalink / raw)
  To: gcc-bugs


Dear forum,

I have a problem with linking of a program I have wrote. Instead of giving
you the entire program, which is pretty large, I have prepared a basic
example that you can find attached to this message. The example uses CMake
to compile.

I have three files:

===== LIB2.CPP =====
#include <iostream>
class Lib2 {
public:
  Lib2() {
    std::cout << "Lib2" << std::endl;
  }
};
Lib2 lib2;

===== LIB1.CPP =====
#include <iostream>
class Lib1 {
  Lib1() {
    std::cout << "Lib1" << std::endl;
  }
};

===== MAIN.CPP ====
#include <iostream>
int main() {
  std::cout << "Ciao" << std::endl;
  return 0;
}

The file lib2.cpp is compiled into a dynamic library called lib2. The file
lib1.cpp is compiled into a dynamic library called lib1 and that links to
lib2. Finally, main.cpp is compiled into an executable that links to lib1.
The dependencies are thus:

lib2 --> lib1 --> testing

Now: if I compile the program with g++ 4.5.2, the programs outputs:

Lib2
Ciao

whereas if I compile with g++ 4.6.1, the program outputs:

Ciao

For me this is a problem, as my program depends on the behavior of g++
4.5.2. I would like to ask you if:

1. this is a new feature - in which case, how do fix the problem?
2. this is a known bug - in which case I apologize for asking, but I
couldn't find it in the bug list.

Thanks a lot in advance for your help.

Cheers,
Carlo


-- 
View this message in context: http://old.nabble.com/Different-linking-behavior-between-g%2B%2B-4.5.2-and-4.6.1-tp32849125p32849125.html
Sent from the gcc - bugs mailing list archive at Nabble.com.


^ permalink raw reply	[flat|nested] 4+ messages in thread
* Re: Different linking behavior between g++ 4.5.2 and 4.6.1
@ 2011-11-15 18:36 Jonathan Wakely
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2011-11-15 18:36 UTC (permalink / raw)
  To: Carlo Pinciroli; +Cc: gcc-bugs

This is the gcc-bugs list, for automated mails from our Bugzilla
database.  Your email should probably have been sent to the gcc-help
list.

http://gcc.gnu.org/lists.html


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-11-15 18:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-15 17:50 Different linking behavior between g++ 4.5.2 and 4.6.1 Carlo Pinciroli
2011-11-15 18:39 ` Andrew Pinski
2011-11-15 19:25   ` Carlo Pinciroli
2011-11-15 18:36 Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).