<html>
    <head>
      <base href="https://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 --- - Constructing a vector with an initializer list generates more code than push_back / emplace_back"
   href="https://llvm.org/bugs/show_bug.cgi?id=30317">30317</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Constructing a vector with an initializer list generates more code than push_back / emplace_back
          </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>Windows NT
          </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>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>dcheng@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Simple test case:

#include <stdio.h>

#include <string>
#include <vector>

void PrintVector(const std::vector<std::string>& strings) {
  for (const auto& s : strings) {
    printf("%s\n", s.data());
  }
}

void Foo() {
  std::vector<std::string> names;
  names.push_back("abc");
  names.push_back("def");
  names.push_back("ghi");
  PrintVector(names);
}

void Bar() {
  std::vector<std::string> names{
    "abc",
    "def",
    "ghi",
  };
  PrintVector(names);
}

int main() {
  Foo();
  Bar();
}

With -O2, the function sizes are roughly the same. Foo() is 847 bytes, Bar() is
844 bytes.
With -O1, Foo() is much smaller at 294 bytes, while Bar() is 396 bytes.</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>