<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 --- - clang does not omit unnecessary memory allocations with -std=c++1{y,z}"
   href="http://llvm.org/bugs/show_bug.cgi?id=21145">21145</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang does not omit unnecessary memory allocations with -std=c++1{y,z}
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </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++1y
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>sneves@dei.uc.pt
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider the following function:

int f() {
  int * x = new int(123);
  int z = *x;
  delete x;
  return z;
}

N3664, which is implemented on clang 3.4 onward, states that the above `new`
expression is allowed not to result in an explicit allocation. However, it
appears that clang only avoids the allocation when using -std=c++98 or
-std=c++11. Here is the abridged output of `clang -std=c++11 -O3 f.cpp`:

f():                                  # @f()
    movl    $123, %eax
    retq

And here is the output of `clang -std=c++1y -O3 f.cpp`:

f():                                  # @f()
    pushq    %rax
    movl    $4, %edi
    callq    operator new(unsigned long)
    movl    $123, (%rax)
    movl    $4, %esi
    movq    %rax, %rdi
    callq    operator delete(void*, unsigned long)
    movl    $123, %eax
    popq    %rdx
    retq

It would seem that C++14 mode actually disables N3664, instead of enabling it.</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>