By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,406 Members | 1,020 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,406 IT Pros & Developers. It's quick & easy.

linkage -O3 templates

P: n/a
Hi,

I've got some linking trouble. I've got a project with many template
classes. Everything works fine as long as I do not use -O3 for optimizing.
If I use it, I get some linker error about undefined references. All
methods, the linker misses, are empty member functions of template classes.
So the compiler optimizes them away with -O3, but the linker still needs
them!?!. What can I do about it?

regards,
Alex
Jul 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Alexander Stippler wrote:
Hi,

I've got some linking trouble. I've got a project with many template
classes. Everything works fine as long as I do not use -O3 for optimizing.
If I use it, I get some linker error about undefined references. All
methods, the linker misses, are empty member functions of template
classes. So the compiler optimizes them away with -O3, but the linker
still needs them!?!. What can I do about it?


You say those functions are empty - so why do they exist? Apart from
trimming pointless code your other option seems to be to look at the GCC
man page and enable the individual optimisations that would be done by -O3
minus the one that removes empty functions.

--
The generation of random numbers is too important
to be left to chance. -- Robert R. Coveyou

Jul 19 '05 #2

P: n/a
Jacques Labuschagne wrote:
You say those functions are empty - so why do they exist? Apart from
trimming pointless code your other option seems to be to look at the GCC
man page and enable the individual optimisations that would be done by -O3
minus the one that removes empty functions.


Sometimes one needs empty functions. Just think of constructors, which would
not exist otherwise (as soon as you have another constructor). And I'm not
looking for a workaround. I'm looking for a solution.

regards,
alex
Jul 19 '05 #3

P: n/a
Alexander Stippler wrote:
Sometimes one needs empty functions. Just think of constructors, which would
not exist otherwise (as soon as you have another constructor). And I'm not
looking for a workaround. I'm looking for a solution.


It could be a bug in the optimizer, have you tried to compile it with a
different version of the compiler? (2.95, 3.0, 3.1, ...)

Hmm, you probably have to ask this on a gcc mailing list. Maybe they can
help you.

Christoph

Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.