https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45221
Andrew Pinski changed:
What|Removed |Added
Target Milestone|--- |8.0
Resolution|---
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45221
Navin Kumar changed:
What|Removed |Added
Version|4.5.0 |4.6.0
--- Comment #11 from Navin Kumar 201
--- Comment #10 from navin dot kumar at gmail dot com 2010-08-07 17:27
---
Richard, correct references in C++ cannot bind to NULL. So gcc should derive
non-NULL-ness when the argument is a reference. It seems to correctly do this
in the case of foo3 and fooB, but fails to do so for fo
--- Comment #9 from rguenth at gcc dot gnu dot org 2010-08-07 16:27 ---
(In reply to comment #7)
> Richard, if you can't derive non-NULL-ness from X& y = *x, how do foo3 and
> fooB
> avoid the null check?
For both cases the C++ frontend do not emit the NULL check.
--
http://gcc.gn
--- Comment #8 from rguenth at gcc dot gnu dot org 2010-08-07 16:25 ---
Which means that if the language guarantees that for
Base2* fooA(Derived* x)
{
Base2& y = *x;
return &y;
}
x being a null pointer invokes undefined behavior (because references can't
bind to nothing(?)) the
--- Comment #7 from navin dot kumar at gmail dot com 2010-08-07 16:22
---
Richard, if you can't derive non-NULL-ness from X& y = *x, how do foo3 and fooB
avoid the null check?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45221
--- Comment #6 from rguenth at gcc dot gnu dot org 2010-08-07 16:19 ---
(In reply to comment #5)
> Hi Richard,
>
> Your explanation doesn't explain why foo1 would emit poorer assembly than
> foo3.
>
> Or for that matter why fooA would emit poorer assembly than fooB.
>
> In the case o
--- Comment #5 from navin dot kumar at gmail dot com 2010-08-07 15:25
---
Hi Richard,
Your explanation doesn't explain why foo1 would emit poorer assembly than foo3.
Or for that matter why fooA would emit poorer assembly than fooB.
In the case of foo1, foo3, fooA, and fooB, dereferen
--- Comment #4 from rguenth at gcc dot gnu dot org 2010-08-07 10:37 ---
I don't see what the bug is here - this is a feature of the C++ standard,
we can't really "optimize" anything here. 5.2.9/8 ... The null pointer
value is converted to the null pointer value of the destination type.