c++ - Apple LLVM 4.2 segfaults using range-based loops with references -


i'm not sure whether actual bug of llvm comes xcode 4.6.3 (4h1503) or if i'm doing not kosher. snippet of code follows

for(auto &a : matrix[j]) {     = false; } 

where matrix vector of vectors containing booleans. i've been developing visual studio 2012 while , didn't seem problem, application needs run on mac went on , tested it... , bit surprised couldn't compile. upon closer inspection, i've discovered getting full blown segfault clang itself, indication of bad shenanigans going on. isolated piece of code , changed loop more peasant's version using integer index , jazz. works charm.

am correct in assuming original loop supposed working (i've seen similar things here in so, , besides vs2012 didn't have say, really) or making gross mistake , not supposed use references that?

i'd know before reporting bug apple.

edit

#include <vector>  using namespace std;  int main(void) {     vector<vector<bool>> matrix = vector<vector<bool>>(10, vector<bool>(5, false));;      for(auto &a : matrix[0]) {         = true;     }      return 0; } 

compiling clang -x c++ -std=c++11 -stdlib=libc++ yields

0  clang 0x0000000100c57bb2 main + 12932498 stack dump: 0.  program arguments: /usr/bin/clang -cc1 -triple x86_64-apple-macosx10.8.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name rbloop.cpp -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 136 -resource-dir /usr/bin/../lib/clang/4.2 -fmodule-cache-path /var/folders/ny/y4mgzkq14db49kfh7rnvcnshqvrkjz/t/clang-module-cache -stdlib=libc++ -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /users/af6539/src -ferror-limit 19 -fmessage-length 120 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.8.0 -fobjc-dispatch-method=mixed -fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/ny/y4mgzkq14db49kfh7rnvcnshqvrkjz/t/rbloop-auzjp6.o -x c++ rbloop.cpp  1.  rbloop.cpp:9:22: current parser token '{' 2.  rbloop.cpp:6:16: parsing function body 'main' 3.  rbloop.cpp:6:16: in compound statement ('{}') clang: error: unable execute command: segmentation fault: 11 clang: error: clang frontend command failed due signal (use -v see invocation) apple llvm version 4.2 (clang-425.0.28) (based on llvm 3.2svn) target: x86_64-apple-darwin12.4.0 thread model: posix clang: note: diagnostic msg: please submit bug report http://developer.apple.com/bugreporter/ , include crash backtrace, preprocessed source, , associated run script. clang: note: diagnostic msg:  ********************  please attach following files bug report: preprocessed source(s) , associated run script(s) located at: clang: note: diagnostic msg: /var/folders/ny/y4mgzkq14db49kfh7rnvcnshqvrkjz/t/rbloop-hcbryw.cpp clang: note: diagnostic msg: /var/folders/ny/y4mgzkq14db49kfh7rnvcnshqvrkjz/t/rbloop-hcbryw.sh clang: note: diagnostic msg:   ******************** 

i'm not pasting files mentioned @ end because ridiculously large , don't seem add information (just bunch of library headers , exact code above pasted @ end of file). besides, if had same compiler have, should able them yourselves.

as howard says, compiler should not give stack trace produce error message , can see gcc produce good diagnostic. reason receive error std::vector<bool> specialization , thread gives details. @ least in gcc , clang proxy acts reference since temporary object can not take reference , don't need since changes reflected back, not sure visual studio though. example demonstrates mean.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -