From 4ad4d899a4627e18b36951b586007849e698296a Mon Sep 17 00:00:00 2001 From: "Salem B." Date: Mon, 26 Jan 2026 09:37:26 +0100 Subject: [PATCH 1/2] fix failings builds in GCC15+ compilers GCC15 compilers have become very strict in refusing situations that may lead to UB these include incompatible pointer conversions This fix attempts to make this code buildable under GCC versions 15 and beyond Signed-off-by: Salem B. --- pcalc.y | 6 +++--- symbol.c | 23 +++++++++++------------ symbol.h | 10 ++++++++-- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/pcalc.y b/pcalc.y index 33274ae..4c05ad4 100644 --- a/pcalc.y +++ b/pcalc.y @@ -96,10 +96,10 @@ list: ; -junk: IBUILTIN str { (*($1->u.iptr))($2->u.str) ; } +junk: IBUILTIN str { (*($1->u.iptr.func_str))($2->u.str) ; } | IBUILTIN { } - | IBUILTIN VAR { (*($1->u.iptr))($2->u.val) ; } - | IBUILTIN expr { (*($1->u.iptr))($2) ; } + | IBUILTIN VAR { (*($1->u.iptr.func_dbl))($2->u.val) ; } + | IBUILTIN expr { (*($1->u.iptr.func_dbl))($2) ; } | STR { printf("%s", $1->name);} | STRVAR { printf("%s", $1->u.str);} ; diff --git a/symbol.c b/symbol.c index 6f367fc..b31cec4 100644 --- a/symbol.c +++ b/symbol.c @@ -34,7 +34,7 @@ CONSTS consts[] = typedef struct { char *name ; - long double (*func)(); + long double (*func)(long double); } BUILTINS; @@ -80,7 +80,7 @@ BUILTINS builtins[] = typedef struct { char *name ; - int (*ifunc)() ; + IFUNC_UNION ifunc ; } IBUILTINS; @@ -88,21 +88,20 @@ IBUILTINS ibuiltins[] = { - {"date", ddate}, - {"print", print}, - {"echo", echo}, - {"_echo", echo_nl}, + {"date", {ddate}}, + {"print", {.func_dbl = print}}, + {"echo", {echo}}, + {"_echo", {echo_nl}}, - {"DATE", ddate}, - {"PRINT", print}, - {"ECHO", echo}, - {"_ECHO", echo_nl}, + {"DATE", {ddate}}, + {"PRINT", {.func_dbl = print}}, + {"ECHO", {echo}}, + {"_ECHO", {echo_nl}}, - {NULL, (void *) 0} + {nullptr, {nullptr}} } ; - void init_sym(void) { diff --git a/symbol.h b/symbol.h index aa2382e..0158f65 100644 --- a/symbol.h +++ b/symbol.h @@ -3,6 +3,12 @@ /* -------- Macros: ------------------------------------------------------ */ +typedef union +{ + int (*func_str)(const char*); + int (*func_dbl)(long double); +} IFUNC_UNION; + typedef struct Symbol { /* symbol table entry */ char *name ; short type ; /* VAR, BLTIN, UNDEF */ @@ -13,8 +19,8 @@ typedef struct Symbol { /* symbol table entry */ int ival; /* if VAR */ long long lval; /* if VAR */ long double val; /* if VAR */ - long double (*ptr)(); /* if BUILTIN */ - int (*iptr)(); /* if IBUILTIN */ + long double (*ptr)(long double); /* if BUILTIN */ + IFUNC_UNION iptr; /* if IBUILTIN */ } u ; struct Symbol *next ; } Symbol ; From 36aaca95cf6f34676b2255845aaddd13ec6c790b Mon Sep 17 00:00:00 2001 From: "Salem B." Date: Mon, 26 Jan 2026 09:44:23 +0100 Subject: [PATCH 2/2] change nullptr back to NULL clang and mingw compilers used in CI do not recognize nullptr as a valid token Signed-off-by: Salem B. --- symbol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/symbol.c b/symbol.c index b31cec4..335ca23 100644 --- a/symbol.c +++ b/symbol.c @@ -98,7 +98,7 @@ IBUILTINS ibuiltins[] = {"ECHO", {echo}}, {"_ECHO", {echo_nl}}, - {nullptr, {nullptr}} + {NULL, (void *) 0} } ;