rust/tests/ui/lto/lto-global-allocator.rs
bjorn3 9239d141dc Add test that __rg_oom doesn't get internalized during LTO
Co-Authored-By: Rémy Rakic <remy.rakic+github@gmail.com>
2025-09-06 13:31:41 +00:00

20 lines
425 B
Rust

//@ compile-flags: --crate-type cdylib -C lto
//@ build-pass
//@ no-prefer-dynamic
//@ needs-crate-type: cdylib
use std::alloc::{GlobalAlloc, Layout};
struct MyAllocator;
unsafe impl GlobalAlloc for MyAllocator {
unsafe fn alloc(&self, _layout: Layout) -> *mut u8 {
todo!()
}
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {}
}
#[global_allocator]
static GLOBAL: MyAllocator = MyAllocator;