Hello,<br><br>I was playing around with clang on a pet project where I rewrote a sibling to StringRef (really love this class).<br><br>It turns out I made a couple of errors, but clang still crashes badly (unfortunately no memory dump, didn't managed to find out if it is at all possible on mingw/msys).<br>
<br>Without further ado, here is the file:<br><br>  #include <string><br><br>  class StringRef<br>  {<br>  public:<br>    typedef std::size_t Length;<br><br>    StringRef(std::string const& s): buffer(s.buffer()), length(s.size() {}<br>
<br>    template <Length N><br>    StringRef(char const (&s)[N]): buffer(s), length(N-1) {}<br>  <br>  private:<br>    char const* buffer;<br>    Length length;<br>  }; // class StringRef<br><br><br>And here is Clang output:<br>
<br>$ clang++ -fsyntax-only -std=c++0x crasher.cpp -v<br>clang version 3.0 (trunk 132889)<br>Target: i686-pc-mingw32<br>Thread model: posix<br> "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<br>
clang -cc1 version 3.0 based upon llvm 3.0 hosted on i686-pc-mingw32<br>ignoring nonexistent directory "c:/MinGW/lib/gcc/mingw32/4.5.0/include/c++"<br>ignoring nonexistent directory "c:/MinGW/lib/gcc/mingw32/4.5.0/include/c++/mingw32"<br>
ignoring nonexistent directory "c:/MinGW/lib/gcc/mingw32/4.5.0/include/c++/backward"<br>ignoring nonexistent directory "c:/MinGW/lib/gcc/mingw32/4.4.0/include/c++"<br>ignoring nonexistent directory "c:/MinGW/lib/gcc/mingw32/4.4.0/include/c++/mingw32"<br>
ignoring nonexistent directory "c:/MinGW/lib/gcc/mingw32/4.4.0/include/c++/backward"<br>ignoring nonexistent directory "c:/MinGW/lib/gcc/mingw32/4.3.0/include/c++"<br>ignoring nonexistent directory "c:/MinGW/lib/gcc/mingw32/4.3.0/include/c++/mingw32"<br>
ignoring nonexistent directory "c:/MinGW/lib/gcc/mingw32/4.3.0/include/c++/backward"<br>ignoring nonexistent directory "/usr/local/include"<br>ignoring nonexistent directory "c:/mingw/include"<br>
ignoring nonexistent directory "/usr/include"<br>#include "..." search starts here:<br>#include <...> search starts here:<br> /mingw/lib/gcc/mingw32/4.5.2/include/c++<br> /mingw/lib/gcc/mingw32/4.5.2/include/c++/mingw32<br>
 /mingw/lib/gcc/mingw32/4.5.2/include/c++/backward<br> d:/clang/build-cmake/bin/../lib/clang/3.0/include<br> /mingw/include<br>End of search list.<br>../test/crasher.cpp:16:22: error: expected '}'<br>}; // class StringRef<br>
                     ^<br>../test/crasher.cpp:4:1: note: to match this '{'<br>{<br>^<br>../test/crasher.cpp:8:45: error: no member named 'buffer' in 'std::basic_string<char>'<br>  StringRef(std::string const& s): buffer(s.buffer()), length(s.size() {}<br>
                                          ~ ^<br>../test/crasher.cpp:8:72: error: expected ')'<br>  StringRef(std::string const& s): buffer(s.buffer()), length(s.size() {}<br>                                                                       ^<br>
../test/crasher.cpp:8:62: note: to match this '('<br>  StringRef(std::string const& s): buffer(s.buffer()), length(s.size() {}<br>                                                             ^<br>../test/crasher.cpp:8:56: error: member initializer 'length' does not name a non-static data member or base class<br>
  StringRef(std::string const& s): buffer(s.buffer()), length(s.size() {}<br>                                                       ^~~~~~~~~~~~~~~~~<br>../test/crasher.cpp:14:21: error: expected '{' or ','<br>
  char const* buffer;<br>                    ^<br>../test/crasher.cpp:15:3: error: unknown type name 'Length'<br>  Length length;<br>  ^<br>Stack dump:<br>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<br>
1.      ../test/crasher.cpp:15:10: current parser token 'length'<br>01438F96 (0xB381E376 0x0000003C 0x0000000E 0x01355CB1)<br>0048A83E (0x024A9900 0x022F9370 0x0022E268 0x0022E28C)<br>01355EF3 (0x0225A4C0 0x022F9370 0x7C920041 0x003E0C28)<br>
0048B440 (0x0225A4C0 0x00000001 0x0022E2C8 0x014505D5)<br>01355FF4 (0x0225A4C0 0x00000000 0x00000007 0x0022E2E8)<br>013928DC (0x02284FC8 0x00000006 0x0000011A 0x00000268)<br>004D25EE (0x02284FC8 0x0022E6C4 0x00000000 0x00000001)<br>
004B3F81 (0x02284FC8 0x0022E898 0x004B4714 0x00000000)<br>004B3E8A (0x02284FC8 0x0022E898 0x0022ED14 0x00000000)<br>004AD6BB (0x02284FC8 0x0022ED14 0x00000000 0x00000001)<br>0049F57C (0x02284FC8 0x0022ED14 0x00000003 0x00000000)<br>
0049F5D2 (0x02284FC8 0x0022F118 0x00000003 0x0022F038)<br>0049EF2B (0x02284FC8 0x0022F118 0x00000000 0x0022F11C)<br>0049E5DB (0x02284FC8 0x0022F160 0x022841C8 0x00456349)<br>0049C313 (0x022841C8 0x00000000 0x00000000 0x0143DE78)<br>
00460D24 (0x0225AC30 0x0225A1DC 0x00000013 0xFFFFFFFF)<br>004609AE (0x0225AC30 0x003EFEA8 0x0225AB84 0x00000013)<br>004572F5 (0x003EFEA8 0x0225AC30 0x00000003 0x00000000)<br>0047904B (0x003EFEA8 0x0225A8F0 0x0022F6F0 0x00000000)<br>
004038F5 (0x0022F6F0 0x0022F76C 0x003EFEF4 0x004013C0)<br>00402739 (0x7FFDF000 0x000001E7 0x0022FFA0 0x004010DB)<br>004010DB (0x00000001 0xB5B04D08 0x7C91DCBA 0x7C817074)<br>00401178 (0x000001A6 0x000001E7 0x7FFDF000 0xC0000005)<br>
7C817077 (0x00401160 0x00000000 0x78746341 0x00000020), RegisterWaitForInputIdle()+0073 bytes(s)<br>clang++: error: clang frontend command failed due to signal 1073741819 (use -v to see invocation)<br><br><br><br>I didn't succeeded in reducing the file further, so it seems a gross combination is necessary...<br>
> Removing the call to s.buffer() (non-existing function) make the error go away<br>> Closing the parenthesis after length(s.size() make the error go away<br>> Removing the template constructor make the error go away<br>
<br>Does it ring a bell ?<br><br>-- Matthieu.<br>