https://gcc.gnu.org/bugzilla/show_bug.cgi?id=27336
--- Comment #8 from Guillaume Melquiond
---
It is partly fixed. In callee position, GCC now knows that "this" is non-null.
But in caller position, GCC still cannot make use of that information to remove
non-null checks from dynamic casts. The
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=27336
Manuel López-Ibáñez changed:
What|Removed |Added
CC||manu at gcc dot gnu.org
---
--- Comment #4 from steven at gcc dot gnu dot org 2006-05-01 19:17 ---
Re. comment #2 and comment #3, yes you are expecting too much of the nonnull
attribute. The attribute only applies to function arguments, not to function
results.
--
--- Comment #5 from steven at gcc dot gnu dot org 2006-05-01 19:19 ---
Ehm, right, ignore comment #4.
Yes it is possible.
No, it's not very practical. Your code looks like,
bool f(A *a) {
g(a);
return a;
}
to the middle end. It would take a significant amount of extra work to
--- Comment #6 from rguenth at gcc dot gnu dot org 2006-05-01 19:21 ---
Though it's also not hard to teach VRP to do this.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27336
--- 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
--- Comment #3 from rguenth at gcc dot gnu dot org 2006-04-28 09:33 ---
VRP could extract this information just like it does for loads in
void bar(int);
int foo(int *i)
{
bar(*i);
return i == NULL;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27336
--- Comment #1 from rguenth at gcc dot gnu dot org 2006-04-27 13:10 ---
Confirmed. The frontend needs to tell the middle-end that the argument is
non-NULL. Like by making the methods __attribute__((nonnull(1))).
--
rguenth at gcc dot gnu dot org changed:
What