public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/61982] New: Optimizer does not eliminate stores to destroyed objects
@ 2014-07-31 18:54 avi@cloudius-systems.com
  2014-08-01  8:24 ` [Bug c++/61982] " rguenth at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: avi@cloudius-systems.com @ 2014-07-31 18:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61982

            Bug ID: 61982
           Summary: Optimizer does not eliminate stores to destroyed
                    objects
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: avi@cloudius-systems.com

After a destructor is run, access to the object is forbidden; the object is
turned into a pile of bytes.  Yet the generated code for:


struct X { 
  int i; 
  void clear() { i = 0; } 
}; 

void f(X* x) { 
  x->clear(); 
  x->~X(); 
} 

void g(X* x) {
  x->clear();
  delete x;
}

contains a store for each of f() and g(), stores that should have been
eliminated:

0000000000000000 <f(X*)>:
   0:    c7 07 00 00 00 00        movl   $0x0,(%rdi)
   6:    c3                       retq   
   7:    66 0f 1f 84 00 00 00     nopw   0x0(%rax,%rax,1)
   e:    00 00 

0000000000000010 <g(X*)>:
  10:    c7 07 00 00 00 00        movl   $0x0,(%rdi)
  16:    e9 00 00 00 00           jmpq   1b <g(X*)+0xb>
            17: R_X86_64_PC32    operator delete(void*)-0x4


To be clear, the generated code is correct, but not optimal.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-08-01 18:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-31 18:54 [Bug c++/61982] New: Optimizer does not eliminate stores to destroyed objects avi@cloudius-systems.com
2014-08-01  8:24 ` [Bug c++/61982] " rguenth at gcc dot gnu.org
2014-08-01 15:12 ` jakub at gcc dot gnu.org
2014-08-01 16:32 ` avi@cloudius-systems.com
2014-08-01 16:52 ` glisse at gcc dot gnu.org
2014-08-01 17:10 ` avi@cloudius-systems.com
2014-08-01 18:10 ` daniel.kruegler at googlemail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).