[LLVMbugs] [Bug 9741] New: Crash with range-based for loops, local variables, own collection class and -Wuninitialized

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Apr 18 02:29:02 PDT 2011


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

           Summary: Crash with range-based for loops, local variables, own
                    collection class and -Wuninitialized
           Product: clang
           Version: unspecified
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++0x
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: jonathan.sauer at gmx.de
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


Created an attachment (id=6481)
 --> (http://llvm.org/bugs/attachment.cgi?id=6481)
Clang's log of the compile

The following program results in a crashing clang during compilation when being
compiled with -Wuninitialized (see attached log which also includes the clang
version used):

#include <vector>

template <typename T>
class ArrayRef {
    public:
        T* begin() const { return m_begin; }
        T* end() const { return m_end; }

    private:
        T*    m_begin;
        T*    m_end;
};


//static void doIt(std::vector<int> ints)    // (A)
static void doIt(ArrayRef<int> ints)
{
    // (B) Commenting this line makes the error disappear
    unsigned int u = 0;

    for (const int& i : ints) ;

    // (C)
    //for (auto it = ints.begin(), end = ints.end(); it != end; ++it) ;
}


int main(int, char**)
{
}


The crash does *not* occur, if I
- use std::vector instead of ArrayRef (line A)
- comment line B
- use a traditional for loop with iterators instead of the range-based for
  loop (line C)

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