https://bugs.llvm.org/show_bug.cgi?id=45740

            Bug ID: 45740
           Summary: Valid Template Instantiation triggers assertion
                    failure when Clang/LLVM built with ASSERTs enabled,
                    but does not fail without assertion
           Product: clang
           Version: 10.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++17
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

When Clang and LLVM (version 10.0.0 for both) are compiled from source with
'Release' build and assertions are enabled, the following code:

template <const int& x>
void g() {
    x;
}
template <int>
void f() {
    static constexpr int x = 0;
    g<x>();
}
int main() {
    f<0>();
    return 0;
}

will error out with:

clang++ -std=c++17 template.cpp 

OR

clang++ -std=c++2a template.cpp 

producing:

clang-10:
/xxxxx/llvm-project-llvmorg-10.0.0/clang/lib/Sema/SemaTemplateInstantiate.cpp:3527:
llvm::PointerUnion<clang::Decl*, llvm::SmallVector<clang::VarDecl*, 4>*>*
clang::LocalInstantiationScope::findInstantiationOf(const clang::Decl*):
Assertion `isa<LabelDecl>(D) && "declaration not instantiated in this scope"'
failed.

However, if Clang and LLVM are compiled for RELEASE and assertions are turned
off, the code snippet passes through.

This also affects Clang and LLVM (trunk).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to