[LLVMbugs] [Bug 10131] New: Clang crashes after printing diagnostic

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jun 13 10:25:58 PDT 2011


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

           Summary: Clang crashes after printing diagnostic
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: matthieu.monrocq at gmail.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


Created an attachment (id=6736)
 --> (http://llvm.org/bugs/attachment.cgi?id=6736)
Preprocessed file

This simple (but erroneous) program crashes clang:

  #include <string>

  class StringRef
  {
  public:
    typedef std::size_t Length;

    StringRef(std::string const& s): buffer(s.buffer()), length(s.size() {}

    template <Length N>
    StringRef(char const (&s)[N]): buffer(s), length(N-1) {}

  private:
    char const* buffer;
    Length length;
  }; // class StringRef

(See output at the end of the bug report)

I have not succeeded in reducing the file further, and it contains 2 errors:
- 's.buffer()' as there is no such string method
- 'length(s.size()' as a parenthesis is missing

Interestingly enough removing the 'typedef std::size_t Length' or the template
constructor solve the crash.

Output by Clang:

$ clang++ -fsyntax-only crasher.cpp -v
clang version 3.0 (trunk 132889)
Target: i686-pc-mingw32
Thread model: posix
 "d:/clang/build-cmake/bin/clang++.exe" -cc1 -triple i686-pc-mingw32
-fsyntax-only -disable-free -main-file-name crasher.cpp -mrelocation-model
static -mdisable-fp-elim -mconstructor-aliases -target-cpu pentium4
-momit-leaf-frame-pointer -v -resource-dir
d:/clang/build-cmake/bin\..\lib\clang\3.0 -fdeprecated-macro -ferror-limit 19
-fmessage-length 200 -fobjc-infer-related-result-type -fcxx-exceptions
-fexceptions -fno-use-cxa-atexit -fgnu-runtime -fdiagnostics-show-option
-fcolor-diagnostics -x c++ ../test/crasher.cpp
clang -cc1 version 3.0 based upon llvm 3.0 hosted on i686-pc-mingw32
ignoring nonexistent directory "c:/MinGW/lib/gcc/mingw32/4.5.0/include/c++"
ignoring nonexistent directory
"c:/MinGW/lib/gcc/mingw32/4.5.0/include/c++/mingw32"
ignoring nonexistent directory
"c:/MinGW/lib/gcc/mingw32/4.5.0/include/c++/backward"
ignoring nonexistent directory "c:/MinGW/lib/gcc/mingw32/4.4.0/include/c++"
ignoring nonexistent directory
"c:/MinGW/lib/gcc/mingw32/4.4.0/include/c++/mingw32"
ignoring nonexistent directory
"c:/MinGW/lib/gcc/mingw32/4.4.0/include/c++/backward"
ignoring nonexistent directory "c:/MinGW/lib/gcc/mingw32/4.3.0/include/c++"
ignoring nonexistent directory
"c:/MinGW/lib/gcc/mingw32/4.3.0/include/c++/mingw32"
ignoring nonexistent directory
"c:/MinGW/lib/gcc/mingw32/4.3.0/include/c++/backward"
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "c:/mingw/include"
ignoring nonexistent directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
 /mingw/lib/gcc/mingw32/4.5.2/include/c++
 /mingw/lib/gcc/mingw32/4.5.2/include/c++/mingw32
 /mingw/lib/gcc/mingw32/4.5.2/include/c++/backward
 d:/clang/build-cmake/bin/../lib/clang/3.0/include
 /mingw/include
End of search list.
../test/crasher.cpp:16:22: error: expected '}'
}; // class StringRef
                     ^
../test/crasher.cpp:4:1: note: to match this '{'
{
^
../test/crasher.cpp:8:45: error: no member named 'buffer' in
'std::basic_string<char>'
  StringRef(std::string const& s): buffer(s.buffer()), length(s.size() {}
                                          ~ ^
../test/crasher.cpp:8:72: error: expected ')'
  StringRef(std::string const& s): buffer(s.buffer()), length(s.size() {}
                                                                       ^
../test/crasher.cpp:8:62: note: to match this '('
  StringRef(std::string const& s): buffer(s.buffer()), length(s.size() {}
                                                             ^
../test/crasher.cpp:8:56: error: member initializer 'length' does not name a
non-static data member or base class
  StringRef(std::string const& s): buffer(s.buffer()), length(s.size() {}
                                                       ^~~~~~~~~~~~~~~~~
../test/crasher.cpp:14:21: error: expected '{' or ','
  char const* buffer;
                    ^
../test/crasher.cpp:15:3: error: unknown type name 'Length'
  Length length;
  ^
Stack dump:
0.      Program arguments: d:/clang/build-cmake/bin/clang++.exe -cc1 -triple
i686-pc-mingw32 -fsyntax-only -disable-free -main-file-name crasher.cpp
-mrelocation-model static -mdisable-fp-elim -mconstructor-aliases -target-cpu
pentium4 -momit-leaf-frame-pointer -v -resource-dir
d:/clang/build-cmake/bin\..\lib\clang\3.0 -fdeprecated-macro -ferror-limit 19
-fmessage-length 200 -fobjc-infer-related-result-type -fcxx-exceptions
-fexceptions -fno-use-cxa-atexit -fgnu-runtime -fdiagnostics-show-option
-fcolor-diagnostics -x c++ ../test/crasher.cpp
1.      ../test/crasher.cpp:15:10: current parser token 'length'
01438F96 (0xB381E376 0x0000003C 0x0000000E 0x01355CB1)
0048A83E (0x024A9900 0x022F9370 0x0022E268 0x0022E28C)
01355EF3 (0x0225A4C0 0x022F9370 0x7C920041 0x003E0C28)
0048B440 (0x0225A4C0 0x00000001 0x0022E2C8 0x014505D5)
01355FF4 (0x0225A4C0 0x00000000 0x00000007 0x0022E2E8)
013928DC (0x02284FC8 0x00000006 0x0000011A 0x00000268)
004D25EE (0x02284FC8 0x0022E6C4 0x00000000 0x00000001)
004B3F81 (0x02284FC8 0x0022E898 0x004B4714 0x00000000)
004B3E8A (0x02284FC8 0x0022E898 0x0022ED14 0x00000000)
004AD6BB (0x02284FC8 0x0022ED14 0x00000000 0x00000001)
0049F57C (0x02284FC8 0x0022ED14 0x00000003 0x00000000)
0049F5D2 (0x02284FC8 0x0022F118 0x00000003 0x0022F038)
0049EF2B (0x02284FC8 0x0022F118 0x00000000 0x0022F11C)
0049E5DB (0x02284FC8 0x0022F160 0x022841C8 0x00456349)
0049C313 (0x022841C8 0x00000000 0x00000000 0x0143DE78)
00460D24 (0x0225AC30 0x0225A1DC 0x00000013 0xFFFFFFFF)
004609AE (0x0225AC30 0x003EFEA8 0x0225AB84 0x00000013)
004572F5 (0x003EFEA8 0x0225AC30 0x00000003 0x00000000)
0047904B (0x003EFEA8 0x0225A8F0 0x0022F6F0 0x00000000)
004038F5 (0x0022F6F0 0x0022F76C 0x003EFEF4 0x004013C0)
00402739 (0x7FFDF000 0x000001E7 0x0022FFA0 0x004010DB)
004010DB (0x00000001 0xB5B04D08 0x7C91DCBA 0x7C817074)
00401178 (0x000001A6 0x000001E7 0x7FFDF000 0xC0000005)
7C817077 (0x00401160 0x00000000 0x78746341 0x00000020),
RegisterWaitForInputIdle()+0073 bytes(s)
clang++: error: clang frontend command failed due to signal 1073741819 (use -v
to see invocation)

-- 
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