This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/14863] [3.4 regression] unit-at-a-time causes miscompilation
- From: "rguenth at tat dot physik dot uni-tuebingen dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 Jun 2004 11:07:17 -0000
- Subject: [Bug rtl-optimization/14863] [3.4 regression] unit-at-a-time causes miscompilation
- References: <20040406114325.14863.rguenth@tat.physik.uni-tuebingen.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From rguenth at tat dot physik dot uni-tuebingen dot de 2004-06-02 11:07 -------
Subject: Re: [3.4 regression] unit-at-a-time
causes miscompilation
On Wed, 2 Jun 2004, giovannibajo at libero dot it wrote:
>
> ------- Additional Comments From giovannibajo at libero dot it 2004-06-02 10:57 -------
> Subject: Re: [3.4 regression] unit-at-a-time causes miscompilation
>
> rguenth at tat dot physik dot uni-tuebingen dot de wrote:
>
> > Btw. - why doesn't gcc warn about returning a reference
> > to a temporary there?
>
> It's not easy, because IntervalIterator::operator* returns a reference which is
> valid for its scope. Then, reverse_iterator::operator* thinks that the
> reference it gets is valid and returns it without a warning. EDG doesn't warn
> as well on this testcases. I wonder if the tree gurus can find a way to detect
> this and similar situations.
Hmm, if all is inlined, it should be detectable. If not it is difficult,
because
struct Foo {
int& foo()
{
return *(new int);
}
};
int& bar()
{
Foo f;
return f.foo();
}
is valid. Maybe worth a few false positives. I.e. warn for returned
references to results of methods of local objects.
Btw., just trying to fix the PR by returning a copy in the questionable
places doesn't fix it. There must be something else (or some more
references...).
Richard.
--
Richard Guenther <richard dot guenther at uni-tuebingen dot de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14863