Skip to content

LLVM failed - Assertion && Non-pointer type for constant GetElementPtr expression #18831

@ghost

Description

Hello, this is my first issue, sorry if something is missing.

I was trying to implement an algoritm for finding prime numbers ( Sieve of Eratosthenes ). When trying to debug, this error crashed the build. This happened after I put in the println!() macro and the break after it. I wanted to see the first value with which the range will start.

rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/llvm/lib/IR/Constants.cpp:1992: 
static llvm::Constant* llvm::ConstantExpr::getGetElementPtr(llvm::Constant*, 
llvm::ArrayRef<llvm::Value*>, bool, llvm::Type*): Assertion `C->getType()->isPtrOrPtrVectorTy() && 
"Non-pointer type for constant GetElementPtr expression"' failed.

This is the code that caused it -

use std::num::Float;

static LIMIT: f32 = 100.0;

fn main() {
    let mut values: Vec<bool> = Vec::with_capacity(LIMIT as uint);
    let mut j: uint;

    for _ in range(0, values.capacity()) {
        values.push(true);
    }

    for i in range(2, Float::round(Float::sqrt(LIMIT)) as uint) {
        println!("{}", i);
        break;
        if values[i] == true {
            for count in range(0, values.len()) {
                j = i ^ 2 + count * i;
                if j >= values.len() { break; }
                values[j] = false;
            }
        }

    }

    for i in range(0, values.len()) {
        if values[i] == true {
            println!("{}", i);
        }
    }
}

I am using rustc 0.13.0-nightly (ec28b4a 2014-11-04 03:36:55 +0000)
on Linux arch 3.17.2-1-ARCH #1 SMP PREEMPT Thu Oct 30 20:49:39 CET 2014 x86_64 GNU/Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions