public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rob.desbois at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/60367] Default argument object is not getting constructed
Date: Mon, 03 Mar 2014 11:20:00 -0000	[thread overview]
Message-ID: <bug-60367-4-4zqcFITs9c@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-60367-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60367

--- Comment #5 from rob.desbois at gmail dot com ---
The following is a side-by-side diff of the disassembly of the incorrect
version vs. a correct version (defaulting the parameter with = foo{}). The
object foo has a single member of type char initialized in default, move, and
copy ctors.

 incorrect version                         | correct version
-------------------------------------------|-----------------------------------
push   %rbp                                   push   %rbp
mov    %rsp,%rbp                              mov    %rsp,%rbp
push   %rbx                                   push   %rbx
sub    $0x28,%rsp                          |  sub    $0x18,%rsp
lea    -0x11(%rbp),%rax                       lea    -0x11(%rbp),%rax
mov    %rax,%rdi                              mov    %rax,%rdi
callq  0x400bbe <_ZN3fooC2Ev>              |  callq  0x400bb8 <_ZN3fooC2Ev>
movzbl -0x11(%rbp),%eax                    |  lea    -0x11(%rbp),%rax
mov    %al,-0x30(%rbp)                     <   
lea    -0x30(%rbp),%rax                    <   
mov    %rax,%rdi                              mov    %rax,%rdi
callq  0x4009f0 <_Z6test_a3foo>            |  callq  0x400a50 <_Z6test_b3foo>
lea    -0x11(%rbp),%rax                       lea    -0x11(%rbp),%rax
mov    %rax,%rdi                              mov    %rax,%rdi
callq  0x400bfe <_ZN3fooD2Ev>              |  callq  0x400bf8 <_ZN3fooD2Ev>
mov    $0x0,%eax                              mov    $0x0,%eax
jmp    0x400b65 <main+85>                  |  jmp    0x400b5e <main+78>
mov    %rax,%rbx                              mov    %rax,%rbx
lea    -0x11(%rbp),%rax                       lea    -0x11(%rbp),%rax
mov    %rax,%rdi                              mov    %rax,%rdi
callq  0x400bfe <_ZN3fooD2Ev>              |  callq  0x400bf8 <_ZN3fooD2Ev>
mov    %rbx,%rax                              mov    %rbx,%rax
mov    %rax,%rdi                              mov    %rax,%rdi
callq  0x4008b0 <_Unwind_Resume@plt>          callq  0x4008b0
<_Unwind_Resume@plt>
add    $0x28,%rsp                          |  add    $0x18,%rsp
pop    %rbx                                   pop    %rbx
pop    %rbp                                   pop    %rbp
retq                                          retq



It does look like the incorrect version on the left could be bitwise-copying
the default-constructed object.
As an aside - both versions have a single constructor call but TWO destructor
calls...


  parent reply	other threads:[~2014-03-03 11:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-28 17:30 [Bug c++/60367] New: " rob.desbois at gmail dot com
2014-03-02 15:14 ` [Bug c++/60367] " rob.desbois at gmail dot com
2014-03-02 22:24 ` rob.desbois at gmail dot com
2014-03-03 10:32 ` rob.desbois at gmail dot com
2014-03-03 11:20 ` rob.desbois at gmail dot com [this message]
2014-03-04 11:20 ` redi at gcc dot gnu.org
2014-03-04 11:20 ` redi at gcc dot gnu.org
2014-03-10 19:23 ` jason at gcc dot gnu.org
2014-03-11 21:08 ` reichelt at gcc dot gnu.org
2014-05-13 16:05 ` jason at gcc dot gnu.org
2014-05-13 16:06 ` jason at gcc dot gnu.org
2014-07-08 17:33 ` redi at gcc dot gnu.org
2015-03-03 18:13 ` vhaisman at gmail dot com
2015-03-03 18:15 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-60367-4-4zqcFITs9c@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).