From a1788d59229ac833423c8d9b70cbdba9d895834b Mon Sep 17 00:00:00 2001 From: sebres Date: Fri, 15 Mar 2024 16:02:24 +0100 Subject: [PATCH] fixes tcl-core [1f40aa83c552f597]: suppress integer-overflow trapping (atm, GCC "trapv" only) for intended pieces, avoid unexpected app-crash; back-ported from tcl-core --- generic/tclClockFmt.c | 9 +++++++++ generic/tclDate.c | 9 +++++++++ generic/tclGetDate.y | 9 +++++++++ 3 files changed, 27 insertions(+) diff --git a/generic/tclClockFmt.c b/generic/tclClockFmt.c index a99e53a..9dd8ecb 100644 --- a/generic/tclClockFmt.c +++ b/generic/tclClockFmt.c @@ -56,6 +56,11 @@ static void ClockFrmScnFinalize(ClientData clientData); *---------------------------------------------------------------------- */ +/* int overflows may happens here (expected case) */ +#if defined(__GNUC__) || defined(__GNUG__) +# pragma GCC optimize("no-trapv") +#endif + static inline int _str2int( int *out, @@ -115,6 +120,10 @@ _str2wideInt( *out = val; return TCL_OK; } + +#if defined(__GNUC__) || defined(__GNUG__) +# pragma GCC reset_options +#endif /* *---------------------------------------------------------------------- diff --git a/generic/tclDate.c b/generic/tclDate.c index 4a27b6c..1e25884 100644 --- a/generic/tclDate.c +++ b/generic/tclDate.c @@ -2676,6 +2676,11 @@ LookupWord( return tID; } +/* int overflows may happens here (expected case) */ +#if defined(__GNUC__) || defined(__GNUG__) +# pragma GCC optimize("no-trapv") +#endif + static int TclDatelex( YYSTYPE* yylvalPtr, @@ -2813,6 +2818,10 @@ TclDatelex( } while (Count > 0); } } + +#if defined(__GNUC__) || defined(__GNUG__) +# pragma GCC reset_options +#endif int TclClockFreeScan( diff --git a/generic/tclGetDate.y b/generic/tclGetDate.y index 64620f3..1b5c481 100644 --- a/generic/tclGetDate.y +++ b/generic/tclGetDate.y @@ -877,6 +877,11 @@ LookupWord( return tID; } +/* int overflows may happens here (expected case) */ +#if defined(__GNUC__) || defined(__GNUG__) +# pragma GCC optimize("no-trapv") +#endif + static int TclDatelex( YYSTYPE* yylvalPtr, @@ -1014,6 +1019,10 @@ TclDatelex( } while (Count > 0); } } + +#if defined(__GNUC__) || defined(__GNUG__) +# pragma GCC reset_options +#endif int TclClockFreeScan(