Skip to content

Optimizer optimizes out potential infinite loop #148397

Open
@Pranavkumar-T-S

Description

@Pranavkumar-T-S

All information necessary to reproduce the problem.

It is reproducible in

  • version: clang 18 and above
  • architecture: x86_64, armv8-a, arv7-a
  • optimization flag : O1 and above
  • standard : c++11 and above

The reduced test-case that triggers the bug.

#include <iostream>
#include <unordered_set>
int main() {
    std::unordered_set<int> isPresent;
    isPresent.insert(0);
    // std::cout << "before loop, size of isPresent: " << isPresent.size() << std::endl;
    while (!isPresent.empty()) {
        // std::cout << "infinite loop " << std::endl;
    };
    // std::cout << "after loop " << std::endl;

    return 0;
}

The location where you obtained LLVM (if not from our Git repository).

Metadata

Metadata

Assignees

No one assigned

    Labels

    llvm:optimizationsquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions