<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - Core dump when printing error with invalid range-based for loop"
   href="https://bugs.llvm.org/show_bug.cgi?id=34190">34190</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Core dump when printing error with invalid range-based for loop
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.8
          </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++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>henriquenj@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=18984" name="attach_18984" title="Ubuntu compiler output">attachment 18984</a> <a href="attachment.cgi?id=18984&action=edit" title="Ubuntu compiler output">[details]</a></span>
Ubuntu compiler output

Attempting to compile the following invalid C++ code will result in a core dump
on clang.

#include <string>
#include <utility>
#include <vector>

int main() {
  std::vector<std::pair<int, std::string>> collection;

  for (const &std::pair<int, std::string> : collection) {
  }
}

I used the following command line to trigger the coredump: "clang++ -std=c++11
main.cc -o main && ./main". Changing the & marker to just before the ":" will
not trigger the coredump. The valid range-based loop will not trigger the bug,
example:

for (const std::pair<int, std::string>& item : collection)

I managed to reproduce it on Ubuntu 16.04.2 LTS. "clang++ --version" outputs
"3.8.0-2ubuntu4". It also occurs on OS X El Captain, however Apple clang
versions seems to follow another version scheme, since it shows "Apple LLVM
version 8.0.0 (clang-800.0.42.1)" and I'm unable to relate Ubuntu versions and
Apple versions.

I've attached the full output of the command that triggers the coredump for
Ubuntu. Apple's clang actually say to report the bug on
developer.apple.com/bugreporter, but since this issue do not appear to be
restricted to Apple, I'm reporting it here.

I don't considere it a major bug because the core dump only happens when
compiling invalid code, which would interrupt the compiler anyway. Also the
error description seems to be complete.</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>