This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug rtl-optimization/14863] [3.4 regression] unit-at-a-time causes miscompilation


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]