[LLVMbugs] [Bug 14272] New: clang crash due to nested static initializer list in combination with auto type

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Nov 6 06:12:44 PST 2012


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

             Bug #: 14272
           Summary: clang crash due to nested static initializer list in
                    combination with auto type
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: firzen2510 at freenet.de
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


==== DESCRIPTION ====
Attempting to initialize a multi-dimensional static field using a nested static
initializer and the auto-type feature results in a clang crash.
A simplified test code as well as the crash backtrace follow.
The crash did not occur with a single-dimensional type like std::vector.
Instead of that clang complained about a redefinition of different type
('std::initializer_list<int>' vs 'std::vector<int>')(which is probably right
according to the standard).
Other types haven't been tested.

==== TEST CODE ====
#include <unordered_map>

class foo
{
        static std::unordered_map<int, int> bar;
};

// std::unordered_map<int, int> foo::bar { { 0, 0 } }; // << WORKS
// decltype(foo::bar) foo::bar { { 0, 0 } }; // << WORKS
auto foo::bar { { 0, 0 } }; // << clang CRASH

int main(void)
{ return 0; }

==== CRASH BACKTRACE ====
clang:
/home/impulze/llvm/tools/clang/lib/Sema/../../include/clang/AST/TemplateBase.h:223:
clang::QualType clang::TemplateArgument::getAsType() const: Assertion `Kind ==
Type && "Unexpected kind"' failed.
0  clang           0x00000000020a838f
1  clang           0x00000000020a88b9
2  libpthread.so.0 0x00002ae36be0c060
3  libc.so.6       0x00002ae36c9f63a5 gsignal + 53
4  libc.so.6       0x00002ae36c9f9b0b abort + 379
5  libc.so.6       0x00002ae36c9eed4d __assert_fail + 221
6  clang           0x0000000000659056
7  clang           0x0000000000d6bbb9
clang::Sema::DeduceAutoType(clang::TypeSourceInfo*, clang::Expr*&,
clang::TypeSourceInfo*&) + 2361
8  clang           0x0000000000b5ada6
clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool, bool) +
1334
9  clang           0x0000000000a524e1
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&) + 1745
10 clang           0x0000000000a60f76
clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int, bool,
clang::SourceLocation*, clang::Parser::ForRangeInit*) + 1302
11 clang           0x0000000000a48215
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier) + 245
12 clang           0x0000000000a488e9
13 clang           0x0000000000a4895f
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) + 31
14 clang           0x0000000000a49cd9
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) + 105
15 clang           0x0000000000a4a538
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 184
16 clang           0x0000000000a41fed clang::ParseAST(clang::Sema&, bool, bool)
+ 509
17 clang           0x0000000000784f81 clang::FrontendAction::Execute() + 145
18 clang           0x000000000076a5b4
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 340
19 clang           0x0000000000751d76
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1462
20 clang           0x000000000074ac90 cc1_main(char const**, char const**, char
const*, void*) + 1248
21 clang           0x0000000000733783 main + 787
22 libc.so.6       0x00002ae36c9e130d __libc_start_main + 237
23 clang           0x000000000074a64d
Stack dump:
0.      Program arguments: /home/impulze/install/llvm/bin/clang -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
clang_auto_bug.cc -mrelocation-model static -mdisable-fp-elim -fmath-errno
-masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64
-target-linker-version 2.21.53.20110810 -momit-leaf-frame-pointer -resource-dir
/home/impulze/install/llvm/bin/../lib/clang/3.2 -I /home/impulze/libcxx/include
-I /home/impulze/install/boost-1.51.0/include -fmodule-cache-path
/var/tmp/clang-module-cache -internal-isystem /usr/include/c++/v1
-internal-isystem /usr/local/include -internal-isystem
/home/impulze/install/llvm/bin/../lib/clang/3.2/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-std=c++11 -fdeprecated-macro -fdebug-compilation-dir
/home/firzen/programming/c++11/clang_auto_bug -ferror-limit 19 -fmessage-length
271 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -o /tmp/clang_auto_bug-luayKr.o
-x c++ clang_auto_bug.cc 
1.      clang_auto_bug.cc:12:27: current parser token ';'
clang: error: unable to execute command: Aborted
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.2 (http://llvm.org/git/clang.git
292d67bb69e878104d2cdc1a1f72264e4fc2852a) (http://llvm.org/git/llvm.git
174fbec3dfdf5e20ad5b75dcfcc709011ddb1a12)
Target: x86_64-unknown-linux-gnu
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang++: /home/impulze/llvm/include/llvm/ADT/SmallVector.h:143: const T&
llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2>
>::operator[](unsigned int) const [with T = const char*,
<template-parameter-1-2> = void, llvm::SmallVectorTemplateCommon<T,
<template-parameter-1-2> >::const_reference = const char* const&]: Assertion
`begin() + idx < end()' failed.
0  clang++         0x00000000020a838f
1  clang++         0x00000000020a88b9
2  libpthread.so.0 0x00002b41fd814060
3  libc.so.6       0x00002b41fe3fe3a5 gsignal + 53
4  libc.so.6       0x00002b41fe401b0b abort + 379
5  libc.so.6       0x00002b41fe3f6d4d __assert_fail + 221
6  clang++         0x000000000062acc5
7  clang++         0x00000000007e9596
clang::driver::Driver::generateCompilationDiagnostics(clang::driver::Compilation&,
clang::driver::Command const*) + 870
8  clang++         0x00000000007342f4 main + 3716
9  libc.so.6       0x00002b41fe3e930d __libc_start_main + 237
10 clang++         0x000000000074a64d
Stack dump:
0.      Program arguments: /home/impulze/install/llvm/bin/clang++
-I/home/impulze/libcxx/include -L/home/impulze/build-libcxx/lib -stdlib=libc++
-I/home/impulze/install/boost-1.51.0/include
-L/home/impulze/install/boost-1.51.0/lib -std=c++11 clang_auto_bug.cc -lstdc++
-lsupc++ -Wl,-rpath,/home/impulze/build-libcxx/lib
-Wl,-rpath,/home/impulze/install/boost-1.51.0/lib -Qunused-arguments

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list