Skip to content

Crash with range-based for loops, local variables, own collection class and -Wuninitialized #10113

@llvmbot

Description

@llvmbot
Bugzilla Link 9741
Resolution FIXED
Resolved on Apr 18, 2011 10:51
Version unspecified
OS MacOS X
Attachments Clang's log of the compile
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@zygoloid

Extended Description

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

template
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 ints) // (A)
static void doIt(ArrayRef 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)

Metadata

Metadata

Assignees

Labels

bugzillaIssues migrated from bugzillac++11

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions