[LLVMbugs] [Bug 22090] New: Assertion failure in SemaDecl.cpp with constexpr, templates, and {} initialization

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Jan 4 10:37:06 PST 2015


http://llvm.org/bugs/show_bug.cgi?id=22090

            Bug ID: 22090
           Summary: Assertion failure in SemaDecl.cpp with constexpr,
                    templates, and {} initialization
           Product: clang
           Version: 3.5
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: david at doublewise.net
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Compiling the following file with -std=c++11 or -std=c++14 causes clang to
crash:


constexpr int zero = 0;
template<typename> struct S {
    template<int = zero> void f() {}
};

template<typename T>
void f() {
    constexpr T value{};
}

template void f<S<void>>();



This is very sensitive to minor changes. For instance, all of those template
instantiations seem required, and changing the initialization to

constexpr auto value = T{};

or

constexpr T value;


Make the problem disappear, but changing it to

constexpr T value = T{};

or

constexpr T value = {};

do not.


Associated run script:


 "/home/david/llvm-3.5.0/bin/clang" -cc1 -triple x86_64-unknown-linux-gnu
-emit-obj -mrelax-all -disable-free -main-file-name file.cpp -mrelocation-model
static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases
-munwind-tables -fuse-init-array -target-cpu x86-64 -target-linker-version
2.23.52.0.1 -g -dwarf-column-info -Wno-everything -std=c++1y -fdeprecated-macro
-ferror-limit 19 -fmessage-length 104 -mstackrealign -fobjc-runtime=gcc
-fcxx-exceptions -fexceptions -fdiagnostics-show-option -x c++ file-ff847a.cpp





The error message given is





clang: /home/david/data/llvm-3.5.0/tools/clang/lib/Sema/SemaDecl.cpp:10254:
clang::Decl *clang::Sema::ActOnFinishFunctionBody(clang::Decl *, clang::Stmt *,
bool): Assertion `MaybeODRUseExprs.empty() && "Leftover expressions for odr-use
checking"' failed.
0  clang           0x000000000203c7c5 llvm::sys::PrintStackTrace(_IO_FILE*) +
37
1  clang           0x000000000203cf33
2  libpthread.so.0 0x00000032bec0efa0
3  libc.so.6       0x00000032be435617 gsignal + 55
4  libc.so.6       0x00000032be436d08 abort + 328
5  libc.so.6       0x00000032be42e586
6  libc.so.6       0x00000032be42e632
7  clang           0x0000000000b7c68b
clang::Sema::ActOnFinishFunctionBody(clang::Decl*, clang::Stmt*, bool) + 4107
8  clang           0x0000000000e75f20
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool) + 2576
9  clang           0x0000000000dd4899
clang::Sema::ActOnExplicitInstantiation(clang::Scope*, clang::SourceLocation,
clang::SourceLocation, clang::Declarator&) + 6985
10 clang           0x0000000000a2bd16
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) + 150
11 clang           0x0000000000a93666
clang::Parser::ParseSingleDeclarationAfterTemplate(unsigned int,
clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) + 2710
12 clang           0x0000000000a9244a
clang::Parser::ParseExplicitInstantiation(unsigned int, clang::SourceLocation,
clang::SourceLocation, clang::SourceLocation&, clang::AccessSpecifier) + 154
13 clang           0x0000000000a9232b
clang::Parser::ParseDeclarationStartingWithTemplate(unsigned int,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) + 363
14 clang           0x0000000000a269ba
clang::Parser::ParseDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, unsigned
int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) + 842
15 clang           0x0000000000a17171
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) + 2241
16 clang           0x0000000000a167e4
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 484
17 clang           0x0000000000a12806 clang::ParseAST(clang::Sema&, bool, bool)
+ 422
18 clang           0x00000000008427c7 clang::CodeGenAction::ExecuteAction() +
631
19 clang           0x000000000067c3ce clang::FrontendAction::Execute() + 62
20 clang           0x0000000000655363
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 851
21 clang           0x0000000000639fec
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 2940
22 clang           0x0000000000631296 cc1_main(char const**, char const**, char
const*, void*) + 534
23 clang           0x0000000000637be5 main + 9669
24 libc.so.6       0x00000032be421b45 __libc_start_main + 245
25 clang           0x0000000000630fb1
Stack dump:
0.    Program arguments: /home/david/llvm-3.5.0/bin/clang -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
file.cpp -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
-target-linker-version 2.23.52.0.1 -g -dwarf-column-info -coverage-file
/home/david/delta-test/file.o -resource-dir
/home/david/llvm-3.5.0/bin/../lib/clang/3.5.0 -internal-isystem
/usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.3/../../../../include/c++/4.8.3
-internal-isystem
/usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.3/../../../../include/c++/4.8.3/x86_64-redhat-linux
-internal-isystem
/usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.3/../../../../include/c++/4.8.3/backward
-internal-isystem /usr/local/include -internal-isystem
/home/david/llvm-3.5.0/bin/../lib/clang/3.5.0/include -internal-externc-isystem
/include -internal-externc-isystem /usr/include -Wno-everything -std=c++1y
-fdeprecated-macro -fdebug-compilation-dir /home/david/delta-test -ferror-limit
19 -fmessage-length 104 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions
-fexceptions -fdiagnostics-show-option -o file.o -x c++ file.cpp 
1.    file.cpp:11:27: current parser token ';'
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.5.0 (tags/RELEASE_350/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix

-- 
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/20150104/68eba40a/attachment.html>


More information about the llvm-bugs mailing list