[llvm-bugs] [Bug 31701] New: ICE when initializing a const class with a class static variable template

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jan 19 16:23:42 PST 2017


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

            Bug ID: 31701
           Summary: ICE when initializing a const class with a class
                    static variable template
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: charles_li at playstation.sony.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

We encountered an assertion failure when compiling a test-case with class
static template variables that contains an error.  The crash happens after
an appropriate error message is produced.

This ICE started on revision 245497
$ svn log -r 245497
------------------------------------------------------------------------
r245497 | rsmith | 2015-08-19 13:49:38 -0700 (Wed, 19 Aug 2015) | 2 lines
Internal-linkage variables with constant-evaluatable initializers do not need
to be emitted.
(Also reduces the set of variables that need to be eagerly deserialized when
using PCH / modules.)
------------------------------------------------------------------------

Here is the test case.

$ cat t.cpp
class C {
    template<int i> static int n;
};
template <int M> class D;
template <int M>
template<int i> void D<M>::set() {
    const C c = C::n<i>;
}

Here is the ICE message:

$ clang t.cpp -c
t.cpp:2:32: warning: variable templates are a C++14 extension
[-Wc++14-extensions]
    template<int i> static int n;
                               ^
t.cpp:6:28: error: out-of-line definition of 'set' from class 'D<M>' without
definition
template<int i> void D<M>::set() {
                     ~~~~~~^
clang-4.0: /home/chli/Source/usvn/llvm/tools/clang/lib/AST/Decl.cpp:2164:
clang::APValue*
clang::VarDecl::evaluateValue(llvm::SmallVectorImpl<std::pair<clang::SourceLocation,
clang::PartialDiagnostic> >&) const: Assertion `!Init->isValueDependent()'
failed.

clang-4.0: error: unable to execute command: Aborted (core dumped)
clang-4.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 5.0.0 (trunk 292529)
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/20170120/24cfc0ce/attachment.html>


More information about the llvm-bugs mailing list