From a422aba5786080c9f176cfb0255f81d987b10a08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20H=C3=B6ltermann?= Date: Wed, 27 Mar 2024 15:46:44 +0100 Subject: [PATCH 01/14] Json: improved unmarshalling of `using _: T` fields. `using _: T` fields will now have their members unmarshalled to their parent types reflecting the new behaviour of json.marshall. Example: ```go A :: struct { using _: B, } B :: struct { field: string, } data := `{"field": "Hello World"}` a: A json.unmarshal_string(data, &a) ``` --- core/encoding/json/unmarshal.odin | 50 +++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/core/encoding/json/unmarshal.odin b/core/encoding/json/unmarshal.odin index ba646b0b7..8c21098fb 100644 --- a/core/encoding/json/unmarshal.odin +++ b/core/encoding/json/unmarshal.odin @@ -370,13 +370,13 @@ unmarshal_object :: proc(p: ^Parser, v: any, end_token: Token_Kind) -> (err: Unm fields := reflect.struct_fields_zipped(ti.id) - field_test :: #force_inline proc "contextless" (field_used: [^]byte, index: int) -> bool { - prev_set := field_used[index/8] & byte(index&7) != 0 - field_used[index/8] |= byte(index&7) + field_test :: #force_inline proc "contextless" (field_used: [^]byte, offset: uintptr) -> bool { + prev_set := field_used[offset/8] & byte(offset&7) != 0 + field_used[offset/8] |= byte(offset&7) return prev_set } - field_used_bytes := (len(fields)+7)/8 + field_used_bytes := (reflect.size_of_typeid(ti.id)+7)/8 field_used := intrinsics.alloca(field_used_bytes, 1) intrinsics.mem_zero(field_used, field_used_bytes) @@ -399,13 +399,45 @@ unmarshal_object :: proc(p: ^Parser, v: any, end_token: Token_Kind) -> (err: Unm } } - if use_field_idx >= 0 { - if field_test(field_used, use_field_idx) { + check_children_using_fields :: proc(key: string, parent: typeid) -> ( + offset: uintptr, + type: ^reflect.Type_Info, + found: bool, + ) { + for field in reflect.struct_fields_zipped(parent) { + if field.is_using && field.name == "_" { + offset, type, found = check_children_using_fields(key, field.type.id) + if found { + offset += field.offset + return + } + } + + if field.name == key { + offset = field.offset + type = field.type + found = true + return + } + } + return + } + + offset: uintptr + type: ^reflect.Type_Info + field_found: bool = use_field_idx >= 0 + + if field_found { + offset = fields[use_field_idx].offset + type = fields[use_field_idx].type + } else { + offset, type, field_found = check_children_using_fields(key, ti.id) + } + + if field_found { + if field_test(field_used, offset) { return .Multiple_Use_Field } - offset := fields[use_field_idx].offset - type := fields[use_field_idx].type - name := fields[use_field_idx].name field_ptr := rawptr(uintptr(v.data) + offset) field := any{field_ptr, type.id} From 308e9112f23a37322878968f388a4751d3d54278 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 28 Mar 2024 10:58:40 +0000 Subject: [PATCH 02/14] Disable packing on ARM64 and AMD64 --- src/llvm_abi.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/llvm_abi.cpp b/src/llvm_abi.cpp index 5f5f734fb..724e4e35a 100644 --- a/src/llvm_abi.cpp +++ b/src/llvm_abi.cpp @@ -876,7 +876,8 @@ namespace lbAbiAmd64SysV { if (types.count == 1) { return types[0]; } - return LLVMStructTypeInContext(c, types.data, cast(unsigned)types.count, true); + // TODO(bill): this should be packed but it causes code generation issues + return LLVMStructTypeInContext(c, types.data, cast(unsigned)types.count, false); } gb_internal void classify_with(LLVMTypeRef t, Array *cls, i64 ix, i64 off) { @@ -1165,7 +1166,8 @@ namespace lbAbiArm64 { size_copy -= 8; } GB_ASSERT(size_copy <= 0); - cast_type = LLVMStructTypeInContext(c, types, count, true); + // TODO(bill): this should be packed but it causes code generation issues + cast_type = LLVMStructTypeInContext(c, types, count, false); } return lb_arg_type_direct(return_type, cast_type, nullptr, nullptr); } else { From 63f30a8207cf7729f4791f3d0429a428abc0ca4a Mon Sep 17 00:00:00 2001 From: Laytan Laats Date: Thu, 28 Mar 2024 18:44:21 +0100 Subject: [PATCH 03/14] speed up path_to_fullpath on Linux/MacOS We did some profiling for #3343 and this seems to be the biggest problem. `realpath` is expensive, and we are locking here for no reason that I can think of. This improves the "check procedure bodies" timing (of the linked issue) from 2.4s to .4s on my machine. --- src/build_settings.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/build_settings.cpp b/src/build_settings.cpp index 3a9951cb2..f1a21161f 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -1190,11 +1190,16 @@ gb_internal String path_to_fullpath(gbAllocator a, String s, bool *ok_) { } #elif defined(GB_SYSTEM_OSX) || defined(GB_SYSTEM_UNIX) gb_internal String path_to_fullpath(gbAllocator a, String s, bool *ok_) { + static gb_thread_local StringMap cache; + + String* cached = string_map_get(&cache, s); + if (cached != nullptr) { + return copy_string(a, *cached); + } + char *p; - mutex_lock(&fullpath_mutex); p = realpath(cast(char *)s.text, 0); defer (free(p)); - mutex_unlock(&fullpath_mutex); if(p == nullptr) { if (ok_) *ok_ = false; @@ -1207,10 +1212,14 @@ gb_internal String path_to_fullpath(gbAllocator a, String s, bool *ok_) { // // I have opted for 2 because it is much simpler + we already return `ok = false` + further // checks and processes will use the path and cause errors (which we want). - return copy_string(a, s); + String result = copy_string(a, s); + string_map_set(&cache, copy_string(permanent_allocator(), s), copy_string(permanent_allocator(), result)); + return result; } if (ok_) *ok_ = true; - return copy_string(a, make_string_c(p)); + String result = copy_string(a, make_string_c(p)); + string_map_set(&cache, copy_string(permanent_allocator(), s), copy_string(permanent_allocator(), result)); + return result; } #else #error Implement system From 9a5a39c07dd16997a434660450a6d62d9932f90f Mon Sep 17 00:00:00 2001 From: Laytan Laats Date: Thu, 28 Mar 2024 19:16:55 +0100 Subject: [PATCH 04/14] fix not setting ok in cached code path --- src/build_settings.cpp | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/build_settings.cpp b/src/build_settings.cpp index f1a21161f..1ac9e451f 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -1189,12 +1189,19 @@ gb_internal String path_to_fullpath(gbAllocator a, String s, bool *ok_) { return result; } #elif defined(GB_SYSTEM_OSX) || defined(GB_SYSTEM_UNIX) -gb_internal String path_to_fullpath(gbAllocator a, String s, bool *ok_) { - static gb_thread_local StringMap cache; - String* cached = string_map_get(&cache, s); +struct PathToFullpathResult { + String result; + bool ok; +}; + +gb_internal String path_to_fullpath(gbAllocator a, String s, bool *ok_) { + static gb_thread_local StringMap cache; + + PathToFullpathResult *cached = string_map_get(&cache, s); if (cached != nullptr) { - return copy_string(a, *cached); + if (ok_) *ok_ = cached->ok; + return copy_string(a, cached->result); } char *p; @@ -1213,12 +1220,22 @@ gb_internal String path_to_fullpath(gbAllocator a, String s, bool *ok_) { // I have opted for 2 because it is much simpler + we already return `ok = false` + further // checks and processes will use the path and cause errors (which we want). String result = copy_string(a, s); - string_map_set(&cache, copy_string(permanent_allocator(), s), copy_string(permanent_allocator(), result)); + + PathToFullpathResult cached_result = {}; + cached_result.result = copy_string(permanent_allocator(), result); + cached_result.ok = false; + string_map_set(&cache, copy_string(permanent_allocator(), s), cached_result); + return result; } if (ok_) *ok_ = true; String result = copy_string(a, make_string_c(p)); - string_map_set(&cache, copy_string(permanent_allocator(), s), copy_string(permanent_allocator(), result)); + + PathToFullpathResult cached_result = {}; + cached_result.result = copy_string(permanent_allocator(), result); + cached_result.ok = true; + string_map_set(&cache, copy_string(permanent_allocator(), s), cached_result); + return result; } #else From b7fd51a251539d01772b8106d4080ad19b0596a5 Mon Sep 17 00:00:00 2001 From: Laytan Laats Date: Thu, 28 Mar 2024 19:39:18 +0100 Subject: [PATCH 05/14] add MacOS 14.4.1 to sys/info and odin report --- core/sys/info/platform_darwin.odin | 3 ++- src/bug_report.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core/sys/info/platform_darwin.odin b/core/sys/info/platform_darwin.odin index e8006d175..b95a48bd0 100644 --- a/core/sys/info/platform_darwin.odin +++ b/core/sys/info/platform_darwin.odin @@ -525,6 +525,7 @@ macos_release_map: map[string]Darwin_To_Release = { "23D56" = {{23, 3, 0}, "macOS", {"Sonoma", {14, 3, 0}}}, "23D60" = {{23, 3, 0}, "macOS", {"Sonoma", {14, 3, 1}}}, "23E214" = {{23, 4, 0}, "macOS", {"Sonoma", {14, 4, 0}}}, + "23E224" = {{23, 4, 0}, "macOS", {"Sonoma", {14, 4, 1}}}, } @(private) @@ -568,4 +569,4 @@ map_darwin_kernel_version_to_macos_release :: proc(build: string, darwin: [3]int } else { return nearest, .Nearest } -} \ No newline at end of file +} diff --git a/src/bug_report.cpp b/src/bug_report.cpp index 7b4999943..e919ba67b 100644 --- a/src/bug_report.cpp +++ b/src/bug_report.cpp @@ -888,6 +888,7 @@ gb_internal void report_os_info() { {"23D56", {23, 3, 0}, "macOS", {"Sonoma", {14, 3, 0}}}, {"23D60", {23, 3, 0}, "macOS", {"Sonoma", {14, 3, 1}}}, {"23E214", {23, 4, 0}, "macOS", {"Sonoma", {14, 4, 0}}}, + {"23E224", {23, 4, 0}, "macOS", {"Sonoma", {14, 4, 1}}}, }; From b84a6608065cacb454a5dc531243abeb119c8823 Mon Sep 17 00:00:00 2001 From: Harold Brenes Date: Thu, 28 Mar 2024 21:09:37 -0400 Subject: [PATCH 06/14] Fix incorrect timings on macOS --- src/timings.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/timings.cpp b/src/timings.cpp index baa8b80da..e4165e3c0 100644 --- a/src/timings.cpp +++ b/src/timings.cpp @@ -33,22 +33,23 @@ gb_internal u64 win32_time_stamp__freq(void) { #include -gb_internal u64 osx_time_stamp_time_now(void) { - return mach_absolute_time(); -} - -gb_internal u64 osx_time_stamp__freq(void) { +gb_internal mach_timebase_info_data_t osx_init_timebase_info(void) { mach_timebase_info_data_t data; data.numer = 0; data.denom = 0; - mach_timebase_info(&data); -#if defined(GB_CPU_ARM) - // NOTE(bill, 2021-02-25): M1 Chip seems to have a different freq count - // TODO(bill): Is this truly correct? - return (1000000llu * cast(u64)data.numer) / cast(u64)data.denom; -#else - return (1000000000llu * cast(u64)data.numer) / cast(u64)data.denom; -#endif + kern_return_t r = mach_timebase_info(&data); + GB_ASSERT(r == KERN_SUCCESS); + + return data; +} + +gb_internal u64 osx_time_stamp_time_now(void) { + gb_local_persist mach_timebase_info_data_t data = osx_init_timebase_info(); + return (mach_absolute_time() * cast(u64)data.numer) / cast(u64)data.denom; // Effectively converts to nanoseconds +} + +gb_internal u64 osx_time_stamp__freq(void) { + return 1000000000ull; // Nanoseconds to seconds } #elif defined(GB_SYSTEM_UNIX) From 13b8a5b73d12ed7c6c9a8ca6714a0aa36b82ecf8 Mon Sep 17 00:00:00 2001 From: Harold Brenes Date: Fri, 29 Mar 2024 05:04:40 -0400 Subject: [PATCH 07/14] Reverting to calculated frequency timings method on macOS, but fixed --- src/timings.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/timings.cpp b/src/timings.cpp index e4165e3c0..712e804cb 100644 --- a/src/timings.cpp +++ b/src/timings.cpp @@ -44,12 +44,12 @@ gb_internal mach_timebase_info_data_t osx_init_timebase_info(void) { } gb_internal u64 osx_time_stamp_time_now(void) { - gb_local_persist mach_timebase_info_data_t data = osx_init_timebase_info(); - return (mach_absolute_time() * cast(u64)data.numer) / cast(u64)data.denom; // Effectively converts to nanoseconds + return mach_absolute_time(); } gb_internal u64 osx_time_stamp__freq(void) { - return 1000000000ull; // Nanoseconds to seconds + gb_local_persist mach_timebase_info_data_t data = osx_init_timebase_info(); + return 1000000000ull * cast(u64)data.denom / cast(u64)data.numer; } #elif defined(GB_SYSTEM_UNIX) From e1b545860f06f31f073c7142e3df8a2c1177776b Mon Sep 17 00:00:00 2001 From: rick-masters Date: Fri, 29 Mar 2024 11:05:27 +0000 Subject: [PATCH 08/14] Implement endian conversions for smaller float types. --- src/llvm_backend_const.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/llvm_backend_const.cpp b/src/llvm_backend_const.cpp index bbb0b8387..1ca5f4965 100644 --- a/src/llvm_backend_const.cpp +++ b/src/llvm_backend_const.cpp @@ -730,9 +730,21 @@ gb_internal lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, bo return res; case ExactValue_Float: if (is_type_different_to_arch_endianness(type)) { - u64 u = bit_cast(value.value_float); - u = gb_endian_swap64(u); - res.value = LLVMConstReal(lb_type(m, original_type), bit_cast(u)); + if (type->Basic.kind == Basic_f32le || type->Basic.kind == Basic_f32be) { + f32 f = static_cast(value.value_float); + u32 u = bit_cast(f); + u = gb_endian_swap32(u); + res.value = LLVMConstReal(lb_type(m, original_type), bit_cast(u)); + } else if (type->Basic.kind == Basic_f16le || type->Basic.kind == Basic_f16be) { + f32 f = static_cast(value.value_float); + u16 u = f32_to_f16(f); + u = gb_endian_swap16(u); + res.value = LLVMConstReal(lb_type(m, original_type), f16_to_f32(u)); + } else { + u64 u = bit_cast(value.value_float); + u = gb_endian_swap64(u); + res.value = LLVMConstReal(lb_type(m, original_type), bit_cast(u)); + } } else { res.value = LLVMConstReal(lb_type(m, original_type), value.value_float); } From 915f63b3f92bc17e4a5875623f46e167dcd17322 Mon Sep 17 00:00:00 2001 From: Laytan Laats Date: Fri, 29 Mar 2024 22:42:12 +0100 Subject: [PATCH 09/14] fix a segfault when incomplete types array resizes while processing --- src/llvm_backend_debug.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/llvm_backend_debug.cpp b/src/llvm_backend_debug.cpp index c06026568..9ecacb4f4 100644 --- a/src/llvm_backend_debug.cpp +++ b/src/llvm_backend_debug.cpp @@ -652,7 +652,9 @@ gb_internal void lb_debug_complete_types(lbModule *m) { for_array(debug_incomplete_type_index, m->debug_incomplete_types) { TEMPORARY_ALLOCATOR_GUARD(); - auto const &idt = m->debug_incomplete_types[debug_incomplete_type_index]; + // NOTE(laytan): don't make this a pointer, the array could resize while in this iteration + // and cause a use-after-free at the end. + auto const idt = m->debug_incomplete_types[debug_incomplete_type_index]; GB_ASSERT(idt.type != nullptr); GB_ASSERT(idt.metadata != nullptr); From e6a552e0ce076504e0fcc774f3805eb76441aafa Mon Sep 17 00:00:00 2001 From: Laytan Laats Date: Fri, 29 Mar 2024 22:01:35 +0100 Subject: [PATCH 10/14] fix gb.h to be able to use -fsanitize=address --- src/gb/gb.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/gb/gb.h b/src/gb/gb.h index 702647121..868e11a16 100644 --- a/src/gb/gb.h +++ b/src/gb/gb.h @@ -144,8 +144,6 @@ extern "C" { #error Unknown CPU Type #endif - - #ifndef GB_STATIC_ASSERT #define GB_STATIC_ASSERT3(cond, msg) typedef char static_assertion_##msg[(!!(cond))*2-1] // NOTE(bill): Token pasting madness!! @@ -480,6 +478,13 @@ typedef i32 b32; // NOTE(bill): Prefer this!!! #endif #endif +#if !defined(gb_no_asan) + #if defined(_MSC_VER) + #define gb_no_asan __declspec(no_sanitize_address) + #else + #define gb_no_asan __attribute__((disable_sanitizer_instrumentation)) + #endif +#endif // NOTE(bill): Easy to grep // NOTE(bill): Not needed in macros @@ -3573,7 +3578,7 @@ gb_inline void gb_str_to_upper(char *str) { } -gb_inline isize gb_strlen(char const *str) { +gb_no_asan isize gb_strlen(char const *str) { char const *begin = str; isize const *w; if (str == NULL) { @@ -5679,7 +5684,7 @@ char *gb_path_get_full_name(gbAllocator a, char const *path) { isize path_len = gb_strlen(path); isize cwd_len = gb_strlen(cwd); len = cwd_len + 1 + path_len + 1; - result = gb_alloc_array(a, char, len); + result = gb_alloc_array(a, char, len+1); gb_memmove(result, (void *)cwd, cwd_len); result[cwd_len] = '/'; From 4edcaa6124eac5e73359ff98239be6f447a42f47 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 30 Mar 2024 10:29:20 +0000 Subject: [PATCH 11/14] Try storing a pointer to a fake metadata type in the debug info for a `map` --- src/check_type.cpp | 10 ++++------ src/llvm_backend_debug.cpp | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/check_type.cpp b/src/check_type.cpp index 40a7ec947..2846aae86 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -2526,18 +2526,16 @@ gb_internal void init_map_internal_types(Type *type) { gb_unused(type_size_of(metadata_type)); - // NOTE(bill): [0]^struct{key: Key, value: Value, hash: uintptr} - // This is a zero array to a pointer to keep the alignment to that of a pointer, and not effective the size of the final struct - metadata_type = alloc_type_array(alloc_type_pointer(metadata_type), 0);; + // NOTE(bill): ^struct{key: Key, value: Value, hash: uintptr} + metadata_type = alloc_type_pointer(metadata_type); Scope *scope = create_scope(nullptr, nullptr); Type *debug_type = alloc_type_struct(); - debug_type->Struct.fields = slice_make(permanent_allocator(), 4); - debug_type->Struct.fields[0] = alloc_entity_field(scope, make_token_ident("data"), t_uintptr, false, 0, EntityState_Resolved); + debug_type->Struct.fields = slice_make(permanent_allocator(), 3); + debug_type->Struct.fields[0] = alloc_entity_field(scope, make_token_ident("data"), metadata_type, false, 0, EntityState_Resolved); debug_type->Struct.fields[1] = alloc_entity_field(scope, make_token_ident("len"), t_int, false, 1, EntityState_Resolved); debug_type->Struct.fields[2] = alloc_entity_field(scope, make_token_ident("allocator"), t_allocator, false, 2, EntityState_Resolved); - debug_type->Struct.fields[3] = alloc_entity_field(scope, make_token_ident("__metadata"), metadata_type, false, 3, EntityState_Resolved); debug_type->Struct.scope = scope; debug_type->Struct.node = nullptr; wait_signal_set(&debug_type->Struct.fields_wait_signal); diff --git a/src/llvm_backend_debug.cpp b/src/llvm_backend_debug.cpp index 9ecacb4f4..048f5f933 100644 --- a/src/llvm_backend_debug.cpp +++ b/src/llvm_backend_debug.cpp @@ -748,8 +748,8 @@ gb_internal void lb_debug_complete_types(lbModule *m) { case Type_Map: GB_ASSERT(t_raw_map != nullptr); - // bt = base_type(bt->Map.debug_metadata_type); - bt = base_type(t_raw_map); + bt = base_type(bt->Map.debug_metadata_type); + // bt = base_type(t_raw_map); GB_ASSERT(bt->kind == Type_Struct); /*fallthrough*/ case Type_Struct: From 9271372fefdd932fee2d18312828bcaf8c7aac94 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 30 Mar 2024 13:06:51 +0000 Subject: [PATCH 12/14] Fix `#field_align` issues, by simplifying the LLVM struct type generation --- src/llvm_backend_general.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp index 3c6a51bdc..a77e2ad15 100644 --- a/src/llvm_backend_general.cpp +++ b/src/llvm_backend_general.cpp @@ -2121,16 +2121,18 @@ gb_internal LLVMTypeRef lb_type_internal(lbModule *m, Type *type) { array_add(&fields, padding_type); } - i64 padding_offset = 0; + i64 prev_offset = 0; for (i32 field_index : struct_fields_index_by_increasing_offset(temporary_allocator(), type)) { Entity *field = type->Struct.fields[field_index]; - i64 padding = type->Struct.offsets[field_index] - padding_offset; + i64 offset = type->Struct.offsets[field_index]; + GB_ASSERT(offset >= prev_offset); + i64 padding = offset - prev_offset; if (padding != 0) { LLVMTypeRef padding_type = lb_type_padding_filler(m, padding, type_align_of(field->type)); array_add(&fields, padding_type); } - + field_remapping[field_index] = cast(i32)fields.count; Type *field_type = field->type; @@ -2141,14 +2143,11 @@ gb_internal LLVMTypeRef lb_type_internal(lbModule *m, Type *type) { } array_add(&fields, lb_type(m, field_type)); - - if (!type->Struct.is_packed) { - padding_offset = align_formula(padding_offset, type_align_of(field->type)); - } - padding_offset += type_size_of(field->type); + + prev_offset = offset + type_size_of(field->type); } - i64 end_padding = full_type_size-padding_offset; + i64 end_padding = full_type_size-prev_offset; if (end_padding > 0) { array_add(&fields, lb_type_padding_filler(m, end_padding, 1)); } From 8e1a2094a73205f0494295699ccb31f6610728b7 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 30 Mar 2024 13:46:23 +0000 Subject: [PATCH 13/14] Fix debug info for `map` --- src/check_type.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/check_type.cpp b/src/check_type.cpp index 2846aae86..609b73229 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -2477,10 +2477,6 @@ gb_internal Type *get_map_cell_type(Type *type) { return type; } - if (is_power_of_two(len)) { - return type; - } - i64 padding = size - len*elem_size; GB_ASSERT(padding > 0); From 2bdf5f58ef162a74e132e9a2277aaecccca0df4b Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 30 Mar 2024 14:23:47 +0000 Subject: [PATCH 14/14] Enforce error on old style for/switch l-value --- src/check_expr.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 3a275729f..c7a1b460a 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -2419,10 +2419,6 @@ gb_internal bool check_is_not_addressable(CheckerContext *c, Operand *o) { } gb_internal void check_old_for_or_switch_value_usage(Ast *expr) { - if (!(build_context.strict_style || (check_vet_flags(expr) & VetFlag_Style))) { - return; - } - Entity *e = entity_of_node(expr); if (e != nullptr && (e->flags & EntityFlag_OldForOrSwitchValue) != 0) { GB_ASSERT(e->kind == Entity_Variable);