mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Constant deref of subscript had inserted checks #2818
This commit is contained in:
@@ -121,6 +121,7 @@
|
||||
- Recursive definitions not discovered when initializer is access on other const #2817
|
||||
- Slice overrun detected late hit codegen assert #2822
|
||||
- Compile time dereference of a constant slice was too generous #2821
|
||||
- Constant deref of subscript had inserted checks #2818
|
||||
|
||||
### Stdlib changes
|
||||
- Add `ThreadPool` join function to wait for all threads to finish in the pool without destroying the threads.
|
||||
|
||||
@@ -780,7 +780,7 @@ static inline void llvm_emit_subscript(GenContext *c, BEValue *value, Expr *expr
|
||||
}
|
||||
llvm_emit_subscript_addr(c, value, expr);
|
||||
|
||||
if (safe_mode_enabled() && value->alignment > 1 && !c->emitting_load_store_check && parent_type->type_kind != TYPE_ARRAY)
|
||||
if (!llvm_is_global_eval(c) && safe_mode_enabled() && value->alignment > 1 && !c->emitting_load_store_check && parent_type->type_kind != TYPE_ARRAY)
|
||||
{
|
||||
LLVMValueRef as_int = LLVMBuildPtrToInt(c->builder, value->value, llvm_get_type(c, type_usz), "");
|
||||
LLVMValueRef align = llvm_const_int(c, type_usz, value->alignment);
|
||||
|
||||
14
test/test_suite/globals/taddr_subscript_global.c3t
Normal file
14
test/test_suite/globals/taddr_subscript_global.c3t
Normal file
@@ -0,0 +1,14 @@
|
||||
// #target: macos-x64
|
||||
module test;
|
||||
int a;
|
||||
fn int main()
|
||||
{
|
||||
static any[] x = { &&((&a + 1)[2]), };
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* #expect: test.ll
|
||||
|
||||
@test.a = global i32 0, align 4
|
||||
@.__const_slice = private unnamed_addr global [1 x %any] [%any { ptr getelementptr inbounds (i8, ptr getelementptr (i8, ptr @test.a, i64 4), i64 8), i64 ptrtoint (ptr @"$ct.int" to i64) }], align 16
|
||||
@main.x = internal unnamed_addr global %"any[]" { ptr @.__const_slice, i64 1 }, align 8
|
||||
Reference in New Issue
Block a user