[llvm-bugs] [Bug 34190] New: Core dump when printing error with invalid range-based for loop

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 14 20:31:12 PDT 2017


            Bug ID: 34190
           Summary: Core dump when printing error with invalid range-based
                    for loop
           Product: clang
           Version: 3.8
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: henriquenj at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

Created attachment 18984
  --> https://bugs.llvm.org/attachment.cgi?id=18984&action=edit
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,

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.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170815/648e7b20/attachment.html>

More information about the llvm-bugs mailing list