This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/16179] useless copies not optimized away
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Jun 2004 17:57:53 -0000
- Subject: [Bug tree-optimization/16179] useless copies not optimized away
- References: <20040624175318.16179.rguenth@tat.physik.uni-tuebingen.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-06-24 17:57 -------
This is not a bug, as bar could change f at any time.
So lets examine the code:
extern void bar(void);
int foo(const int &f)
{
const int a = f; <-- load *f
int c = a; <-- move into c from a (all local to foo, c is not take the address of so it cannot be
aliased, likewise for a)
bar(); <-- call bar, can change *f
c = a; <-- move into c from a (all local to foo again)
return c; <-- return the value in c
}
int foo2(const int &f)
{
int c = f; <-- load *f into c
bar(); <-- call bar, can change *f
c = f;<-- load *f into c
return c;
}
So these two code cannot be equivant at all.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16179