https://llvm.org/bugs/show_bug.cgi?id=25180
Bug ID: 25180 Summary: clang assertion failure when trying to infer generic lambda return type from undefined variable Product: clang Version: trunk Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: Frontend Assignee: unassignedclangb...@nondot.org Reporter: fabian.gru...@fadeopolis.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified Created attachment 15080 --> https://llvm.org/bugs/attachment.cgi?id=15080&action=edit Test case cpp file that triggers the assertion failure Clang dies with an assertion failure in the frontend while trying to infer the type of a generic lambda. The lambda consists of an if-statement in which the else branch is just `return baz;' where baz is an undefined variable. This only happens when compiling with `-std=c++14'. With `-std=c++11' an undefined variable error is reported. I managed to reproduce this bug with the Ubuntu clang/llvm 3.8 package from llvm.org [3.8.0-svn250077-1~exp1 (trunk)] and a version built from trunk [(http://llvm.org/git/clang.git 52bc812d7e056333f2a456b8fe8a0dba93e09bfd)(http://llvm.org/git/llvm.git 0dcd516b64fa28ad83e5df4c71c5852cfe9d5683)]. == preprocessed testcase: # 1 "<built-in>" # 1 "clang_bug.cpp" bool quoz(); int foo() { auto bar = []() { if (quoz()) { // The bug is also triggered even if there are compiler errors in this // branch of the if-statement. // I.e. using an undefined variable, etc. // The error mustn't be `severe' enough to stop clang from looking at the // else-branch, though. // in trunk clang-3.8 (52bc812d7e056333f2a456b8fe8a0dba93e09bfd) the bug // is not triggered if the if-statement is not present. // on clang-3.8 from the LLVM Ubuntu repo (3.8.0-svn250077-1~exp1) just // `return baz` is enough. return "default"; } else { // `baz' is not defined in this scope! // If I define name it stops crashing. return baz; } }; } == crash reproducer for trunk clang = (http://llvm.org/git/clang.git 52bc812d7e056333f2a456b8fe8a0dba93e09bfd) = (http://llvm.org/git/llvm.git 0dcd516b64fa28ad83e5df4c71c5852cfe9d5683) # Crash reproducer for clang version 3.8.0 (http://llvm.org/git/clang.git 52bc812d7e056333f2a456b8fe8a0dba93e09bfd) (http://llvm.org/git/llvm.git 0dcd516b64fa28ad83e5df4c71c5852cfe9d5683) # Driver args: "-std=c++14" "clang_bug.cpp" # Original command: "/home/fader/workspace/.build/debug/llvm/bin/clang-3.8" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-main-file-name" "clang_bug.cpp" "-mrelocation-model" "static" "-mthread-model" "posix" "-mdisable-fp-elim" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-munwind-tables" "-fuse-init-array" "-target-cpu" "x86-64" "-dwarf-column-info" "-resource-dir" "/home/fader/workspace/.build/debug/llvm/bin/../lib/clang/3.8.0" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/x86_64-linux-gnu/c++/4.9" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/x86_64-linux-gnu/c++/4.9" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/backward" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/home/fader/workspace/.build/debug/llvm/bin/../lib/clang/3.8.0/include" "-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-std=c++14" "-fdeprecated-macro" "-fdebug-compilation-dir" "/home/fader/Desktop" "-ferror-limit" "19" "-fmessage-length" "134" "-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-o" "/tmp/clang_bug-64f932.o" "-x" "c++" "clang_bug.cpp" "/home/fader/workspace/.build/debug/llvm/bin/clang-3.8" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-main-file-name" "clang_bug.cpp" "-mrelocation-model" "static" "-mthread-model" "posix" "-mdisable-fp-elim" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-munwind-tables" "-fuse-init-array" "-target-cpu" "x86-64" "-dwarf-column-info" "-std=c++14" "-fdeprecated-macro" "-ferror-limit" "19" "-fmessage-length" "134" "-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-x" "c++" "clang_bug-6b2789.cpp" == crash reproducer for clang from llvm.org Ubuntu package # Crash reproducer for Ubuntu clang version 3.8.0-svn250077-1~exp1 (trunk) (based on LLVM 3.8.0) # Driver args: "-std=c++14" "clang_bug.cpp" # Original command: "/usr/lib/llvm-3.8/bin/clang" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-disable-llvm-verifier" "-main-file-name" "clang_bug.cpp" "-mrelocation-model" "static" "-mthread-model" "posix" "-mdisable-fp-elim" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-munwind-tables" "-fuse-init-array" "-target-cpu" "x86-64" "-target-linker-version" "2.25" "-dwarf-column-info" "-resource-dir" "/usr/lib/llvm-3.8/bin/../lib/clang/3.8.0" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/x86_64-linux-gnu/c++/4.9" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/x86_64-linux-gnu/c++/4.9" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/backward" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/usr/lib/llvm-3.8/bin/../lib/clang/3.8.0/include" "-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-std=c++14" "-fdeprecated-macro" "-fdebug-compilation-dir" "/home/fader/Desktop" "-ferror-limit" "19" "-fmessage-length" "134" "-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-o" "/tmp/clang_bug-9f98d4.o" "-x" "c++" "clang_bug.cpp" "/usr/lib/llvm-3.8/bin/clang" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-disable-llvm-verifier" "-main-file-name" "clang_bug.cpp" "-mrelocation-model" "static" "-mthread-model" "posix" "-mdisable-fp-elim" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-munwind-tables" "-fuse-init-array" "-target-cpu" "x86-64" "-target-linker-version" "2.25" "-dwarf-column-info" "-std=c++14" "-fdeprecated-macro" "-ferror-limit" "19" "-fmessage-length" "134" "-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-x" "c++" "clang_bug-a32268.cpp" -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs