llvm crash

Originator:nkhorman
Number:rdar://39926584 Date Originated:5/2/2018
Status:open Resolved:
Product:llvm Product Version:Apple LLVM version 9.0.0 (clang-900.0.38)
Classification:bug Reproducible:yes
 
Summary:
command line llvm crashes when compiling source attached in crash.tgz as per direction by llvm

Steps to Reproduce:
c++ -Wno-unused -MP -MD -std=c++11 -g3 -ggdb -I. -c main.cpp -o main.o

Expected Results:
It shouldn't crash

Compiler output:
--- start ---
(neal@Neal-MBP3-55.local) 18:52:22
(553 / 53) [~/src/vs.git/t2]$: make
c++ -Wno-unused -MP -MD -std=c++11 -g3 -ggdb -I. -c main.cpp -o main.o
clang: error: unable to execute command: Segmentation fault: 11
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Apple LLVM version 9.0.0 (clang-900.0.38)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to http://developer.apple.com/bugreporter/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /var/folders/6r/cw6_jzqx32n9pq4rl5jy2wkw0000gn/T/main-32bc2f.cpp
clang: note: diagnostic msg: /var/folders/6r/cw6_jzqx32n9pq4rl5jy2wkw0000gn/T/main-32bc2f.sh
clang: note: diagnostic msg: Crash backtrace is located in
clang: note: diagnostic msg: /Users/neal/Library/Logs/DiagnosticReports/clang_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang: note: diagnostic msg:

********************
make: *** [main.o] Error 254

(neal@Neal-MBP3-55.local) 18:53:54
--- end ---


--- main.cpp ---
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <dispatch/dispatch.h>
#include <functional>

class C1Sub
{
public: 
        C1Sub() {};
        virtual ~C1Sub() {};
};


class C1
{
public: 
        C1() {};
        virtual ~C1() {};

        C1Sub Sub(std::function<void()> fn) { return C1Sub(); };
};

class C2Item
{
public: 
        C2Item() {};
        virtual~C2Item() {};

        bool Test() const { return false; };
};

class C2
{
public: 
        C2() {};
        virtual ~C2() {};

        void Iterate(std::function<void(C2Item const &ifi)> fn) {};
};

C1 gHub;
C2 gIfi;

void test1()
{
        __block C1Sub c1sub = gHub.Sub([&]()
        {
                gIfi.Iterate(
                        [&](C2Item const &ifi)
                        {
                                // All is fine if there is no conditional flow logic interal to this block
                                // ie. if(), switch(), while(), for() 
                                if(ifi.Test()) // <<<----- comment this line to compile 
                                {
                                }
                        });
        });
}

int main(int argc, char **argv)
{
        test1();

        return 0;
}

--- end main.cpp ---

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!