This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/27336] "this" pointer is not assumed to be not null
- From: "guillaume dot melquiond at ens-lyon dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Apr 2006 09:03:35 -0000
- Subject: [Bug c++/27336] "this" pointer is not assumed to be not null
- References: <bug-27336-7904@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from guillaume dot melquiond at ens-lyon dot fr 2006-04-28 09:03 -------
I tried setting the nonnull attribute, it indeed allowed the optimization. In
particular, codes containing dynamic casts are now straight lines. This is a
nice improvement. Unfortunately GCC was not able to go further and use this
information in the caller in order to optimize it:
struct A { bool g() __attribute__((nonnull)); }
bool f(A *a) {
a->g();
return a;
}
Am I expecting too much from the nonnull attribute? (The documentation does not
seem to cover this point.) Or would it be reasonnable for the middle-end to
implement such an optimization?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27336