<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - missed optimization: unused std::string"
   href="http://llvm.org/bugs/show_bug.cgi?id=17151">17151</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>missed optimization: unused std::string
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>ruslan_baratov@yahoo.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre><span class="quote">>cat test.cpp</span >
#include <string>

void foo() {
  std::string a = "abc";
}

void boo() {
}

Expected, that both 'foo' and 'boo' produce same asm, but it's not:

<span class="quote">>clang++ -O3 -stdlib=libc++ -save-temps -O3 -c -fomit-frame-pointer test.cpp
>cat test.s</span >
__Z3foov:                               ## @_Z3foov
    pushq    %rbx
    subq    $32, %rsp
    leaq    8(%rsp), %rbx
    leaq    L_.str(%rip), %rsi
    movq    %rbx, %rdi
    movl    $3, %edx
    callq   
__ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm
    movq    %rbx, %rdi
    callq   
__ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEED1Ev
    addq    $32, %rsp
    popq    %rbx
    ret

__Z3boov:                               ## @_Z3boov
    ret</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>