Skip to content

Empty BitVector call getData() got "Assertion `idx < size()' failed." #65500

Closed
@wingrez

Description

@wingrez

I migrated my project from llvm12.0 to llvm15.0 and found a problem. It worked fine in version 12.0, but in version 15.0 it got an assertion failure.

This is a reproduct code snippet:

BitVector bv;
auto d = bv.getData();
std::cout << d.size() << std::endl;

I expect it to work. But got:

llvm-project/llvm/include/llvm/ADT/SmallVector.h:298: const T& llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::operator[](llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::size_type) const [with T = long unsigned int; <template-parameter-1-2> = void; llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::const_reference = const long unsigned int&; llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::size_type = long unsigned int]: Assertion `idx < size()' failed.

This problem still occurs in recent versions of llvm. I'm not sure it's a reasonable behavior for an empty BitVector.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions