RFC: New C++ Attribute: final

Gabriel Dos Reis gdr@integrable-solutions.net
Wed Mar 3 17:34:00 GMT 2004


Alexandre Oliva <aoliva@redhat.com> writes:

| On Mar  3, 2004, Gabriel Dos Reis <gdr@integrable-solutions.net> wrote:
| 
| > I believe you completely missed what I was saying.
| 
| No.  You're just thinking of a completely different issue.  I'm
| talking about a case that can't possibly be optimized by GCC without
| an extension, because the optimization would be wrong.  You're
| pointing out cases in which GCC fails to apply an optimization that
| would be correct.  Both are related with turning virtual calls into
| direct calls, but they're not the same.

More to the point, the case I just pointed out *is* an instance where
the function has final semantics and the compiler knows that. 

  (1) In my case, it is known after the class foobar definition
      that foobar::fun is final.  The compiler does not optimize the
      vcall.  I don't think a keyword is needed for that.
      Usage of local classes like that are common.

  (2) in the testcase I gave to Joe, I'm pointing out that GCC still
      don't quite understand pointer-to-member-function and optimize
      accordingly. And this is a case where all information are
      available, in the specific context the call is made.

I'm saying that given both (1) and (2), it looks like we would be
trumping people, for they are already saying "final" and we don't optimize.
Those two cases do not cover all the semantics that a putative "final"
may have; but if we optimize those cases  (which are quite common,
probably more common than the other corner cases) then we may be more
credible in saying that a keyword is needed to do a better job.

-- Gaby



More information about the Gcc mailing list