This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: RFC: New C++ Attribute: final
Joe Buck <Joe.Buck@synopsys.com> writes:
| On Wed, Mar 03, 2004 at 01:42:42AM +0100, Gabriel Dos Reis wrote:
| > But, the pointer to member is a *constant*, in a given scope with
| > defined lifetime. That GCC does not take advantage of that is another
| > problem.
|
| Consider this testcase:
struct A {
int f() { return 7; }
};
template<class T>
inline int
apply(A* p, T f)
{
return (p->*f)();
}
int main()
{
A tab[20];
for (int i = 0; i < 20; ++i)
apply(tab + i, &A::f);
}
[...]
| out. And sure enough, with -O2, GCC 3.3.3 doesn't leave any indirect
| or direct call to std::string::length around.
Look carefully at the assembly generated.
-- Gaby