This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/11131] Unrelated declaration removes inline flag from function


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From nathan@codesourcery.com  2003-06-09 17:42 -------
Subject: Re:  Unrelated declaration removes inline flag from
 function

Ok, what is going on here will be difficult to 'fix' without
pessimizing something.

the specialization
	template <> void A<0>::Unrelated () {}
causes an instantiation of A<0>. At that point A<O>::Foo1 is not declared
inline, but is declared NO_THROW. A<0>::Foo2 is also not declared
inline, but is not declared NO_THROW.

at the call
	a.Foo1 ();
we see the declaration of A<O>::Foo1 already exists. We note that it cannot
throw, so we continue and mark it for later instantiation. We then process the
body of bar for tree inlining and do not inline A<0>::Foo1, as it is not
marked as inline. At the end of compilation we instantiate A<0>::Foo1 using
the definition, and discover that it could be inlined.

At the call
	a.Foo2 ()
we see the declaration of A<0>::Foo1 already exists. We notice that we have
not determined whether it can or cannot throw, we also notice that bar currently
cannot throw. So we instantiate A<0>::Foo1 to see if it does infact turn out
to be a NO_THROW function. That instantiation picks up its inlineable flag.
Notice we would not have done the instantiation if we'd already determined
that Bar could throw.

To fix this bug requires instantiating at all call sites. We tried not
to do that as 'maintaining a stack of active functions is expensive'
(decl2.c:mark_used).

If/when we do whole translation unit optimization, this problem goes away.

nathan


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]