From 67cc9120d3e27fdbda0f7bd7464de9ee3805c964 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 29 May 2021 18:12:21 -0500 Subject: [PATCH] Revert: Partially revert unsigned to signed change in "Bugfix: Compilation/Portability problems exposed when building against musl-libc.". There were problems with the console parameter size, so switching that to signed seems fine. However, switching the more general standard approach from unsigned to signed is more dangerous. Signed operations are much more fickle when overflowing or when using bitwise operations. In fact, the C standards leave a lot of this behavior as undefined. Much of the logic used in operating and manipulating array lengths (as counters or with bitwise operations such as << or >>) is affected by the previous change from signed to unsigned. Avoid these signed problems by reverting this behavario. The console parameter length will remain as a signed. see: 7199b83b9596855a9929d12e5942cc541c194b5f --- level_0/f_type/c/type.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/level_0/f_type/c/type.h b/level_0/f_type/c/type.h index 4a322ae..1268adf 100644 --- a/level_0/f_type/c/type.h +++ b/level_0/f_type/c/type.h @@ -284,13 +284,14 @@ extern "C" { * * There are problems in some libc's and systems that do not handle lengths greater than 2^63. * This is primarily a problem with libc string functions. - * For general compatiblity reasons, this is set to a signed 64-bit integer. + * This may need to be set to a signed 64-bit integer on some system (or a smaller unsigned). + * There are problems, however, with signed integers and binary operations as well as with overflows to be aware of. */ #ifndef _di_f_array_t_ - typedef f_number_signed_t f_array_length_t; + typedef f_number_unsigned_t f_array_length_t; - #define f_array_length_t_size f_type_size_64_positive - #define f_array_length_t_size_max f_type_size_max_64_positive + #define f_array_length_t_size f_number_t_size_unsigned + #define f_array_length_t_size_max f_number_t_size_max_unsigned #endif // _di_f_array_t_ /** -- 1.8.3.1