Skip to content

Box<T, &A> and LTO: Explicit gep type does not match pointee type of pointer operand #95036

Closed
@exrook

Description

@exrook

Code

Only when building with lto = thin or lto = fat do I trigger this issue. Found while working on #77438.
Compile test that triggers the issue: exrook@b2652ba

lto_box_allocator/lib.rs

#![feature(allocator_api)]
#![feature(bench_black_box)]
use std::alloc::Global;
use std::hint::black_box;

pub fn f() {
    let mut node = Box::new_in(Node {
        v: &(),
        b: false,
    }, &Global);
    node.b = true;
    black_box(node); // without this bug only triggers when built without optimizations
}

struct Node {
    v: &'static (),
    b: bool,
}

box_consumer/main.rs

extern crate lto_box_allocator;

fn main() {
    lto_box_allocator::f();
}

Meta

rustc --version --verbose:

rustc 1.61.0-nightly (458262b13 2022-03-09)
binary: rustc
commit-hash: 458262b1315e0de7be940fe95e111bb045e4a2a4
commit-date: 2022-03-09
host: x86_64-unknown-linux-gnu
release: 1.61.0-nightly
LLVM version: 14.0.0

Error output

lto=thin

error: failed to prepare thin LTO module: Explicit gep type does not match pointee type of pointer operand (Producer: 'LLVM14.0.0-rust-dev' Reader: 'LLVM 14.0.0-rust-dev')

error: aborting due to previous error

lto=fat

warning: Explicit gep type does not match pointee type of pointer operand (Producer: 'LLVM14.0.0-rust-dev' Reader: 'LLVM 14.0.0-rust-dev')

error: failed to load bitcode of module "lto-box-allocator.lto_box_allocator.c2c2224e-cgu.0.rcgu.o":

error: aborting due to previous error; 1 warning emitted

Metadata

Metadata

Assignees

Labels

A-LTOArea: Link-time optimization (LTO)A-allocatorsArea: Custom and system allocatorsC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions