Skip to content

Commit

Permalink
fixes tcl-core [1f40aa83c552f597]: suppress integer-overflow trapping…
Browse files Browse the repository at this point in the history
… (atm, GCC "trapv" only) for intended pieces, avoid unexpected app-crash; back-ported from tcl-core
  • Loading branch information
sebres committed Mar 15, 2024
1 parent 42649e0 commit a1788d5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions generic/tclClockFmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -115,6 +120,10 @@ _str2wideInt(
*out = val;
return TCL_OK;
}

#if defined(__GNUC__) || defined(__GNUG__)
# pragma GCC reset_options
#endif

/*
*----------------------------------------------------------------------
Expand Down
9 changes: 9 additions & 0 deletions generic/tclDate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -2813,6 +2818,10 @@ TclDatelex(
} while (Count > 0);
}
}

#if defined(__GNUC__) || defined(__GNUG__)
# pragma GCC reset_options
#endif

int
TclClockFreeScan(
Expand Down
9 changes: 9 additions & 0 deletions generic/tclGetDate.y
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -1014,6 +1019,10 @@ TclDatelex(
} while (Count > 0);
}
}

#if defined(__GNUC__) || defined(__GNUG__)
# pragma GCC reset_options
#endif

int
TclClockFreeScan(
Expand Down

0 comments on commit a1788d5

Please sign in to comment.