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 tree-optimization/16179] useless copies not optimized away


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


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