Fails to compile due to "type narrowing" error. #1

Closed
opened 2020-09-18 11:03:07 +00:00 by zilti · 0 comments
Owner

Infos from Bunny351 on #chicken:

apparently "char c = 128;" fails in newer C++ compilers

Here's a diff to be applied to chicken.h:

diff --git a/chicken.h b/chicken.h
index d75fe04f..ad3ba9da 100644
--- a/chicken.h
+++ b/chicken.h
@@ -1487,17 +1487,17 @@ typedef void (C_ccall *C_proc)(C_word, C_word *) C_noret;
 #ifdef C_BIG_ENDIAN
 # ifdef C_SIXTY_FOUR
 #  define C_lihdr(x, y, z)              ((C_LAMBDA_INFO_TYPE >> 56) & 0xff), \
-                                        0, 0, 0, 0, (x), (y), (z)
+                                        0, 0, 0, 0, (x), (y), ((C_char)(z))
 # else
 #  define C_lihdr(x, y, z)              ((C_LAMBDA_INFO_TYPE >> 24) & 0xff), \
-                                        (x), (y), (z)
+                                        (x), (y), ((C_char)(z))
 # endif
 #else
 # ifdef C_SIXTY_FOUR
-#  define C_lihdr(x, y, z)              (z), (y), (x), 0, 0, 0, 0, \
+#  define C_lihdr(x, y, z)              ((C_char)(z)), (y), (x), 0, 0, 0, 0, \
                                         ((C_LAMBDA_INFO_TYPE >> 56) & 0xff)
 # else
-#  define C_lihdr(x, y, z)              (z), (y), (x), \
+#  define C_lihdr(x, y, z)              ((C_char)(z)), (y), (x), \
                                         ((C_LAMBDA_INFO_TYPE >> 24) & 0xff)
 # endif
 #endif
Infos from Bunny351 on #chicken: apparently "char c = 128;" fails in newer C++ compilers Here's a diff to be applied to `chicken.h`: ```diff diff --git a/chicken.h b/chicken.h index d75fe04f..ad3ba9da 100644 --- a/chicken.h +++ b/chicken.h @@ -1487,17 +1487,17 @@ typedef void (C_ccall *C_proc)(C_word, C_word *) C_noret; #ifdef C_BIG_ENDIAN # ifdef C_SIXTY_FOUR # define C_lihdr(x, y, z) ((C_LAMBDA_INFO_TYPE >> 56) & 0xff), \ - 0, 0, 0, 0, (x), (y), (z) + 0, 0, 0, 0, (x), (y), ((C_char)(z)) # else # define C_lihdr(x, y, z) ((C_LAMBDA_INFO_TYPE >> 24) & 0xff), \ - (x), (y), (z) + (x), (y), ((C_char)(z)) # endif #else # ifdef C_SIXTY_FOUR -# define C_lihdr(x, y, z) (z), (y), (x), 0, 0, 0, 0, \ +# define C_lihdr(x, y, z) ((C_char)(z)), (y), (x), 0, 0, 0, 0, \ ((C_LAMBDA_INFO_TYPE >> 56) & 0xff) # else -# define C_lihdr(x, y, z) (z), (y), (x), \ +# define C_lihdr(x, y, z) ((C_char)(z)), (y), (x), \ ((C_LAMBDA_INFO_TYPE >> 24) & 0xff) # endif #endif ```
zilti closed this issue 2020-09-23 23:19:05 +00:00
Sign in to join this conversation.
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Chicken/qml-old#1
No description provided.