diff options
author | sebres <sebres@users.sourceforge.net> | 2024-03-15 14:14:47 (GMT) |
---|---|---|
committer | sebres <sebres@users.sourceforge.net> | 2024-03-15 14:14:47 (GMT) |
commit | f81c7c620816c8a89bc363903c29f338bf7d6162 (patch) | |
tree | 67c647f543ac69a49a31606c094f5c6796bd3f88 | |
parent | a20d3aea075e2b3990de10e1637613c7278d6acc (diff) | |
download | tcl-f81c7c620816c8a89bc363903c29f338bf7d6162.zip tcl-f81c7c620816c8a89bc363903c29f338bf7d6162.tar.gz tcl-f81c7c620816c8a89bc363903c29f338bf7d6162.tar.bz2 |
fixes [1f40aa83c552f597]: suppress integer-overflow trapping (atm, GCC "trapv" only) for intended pieces, avoid unexpected app-crash;
test cases (knownBug) reverted.
-rw-r--r-- | generic/tclClockFmt.c | 9 | ||||
-rw-r--r-- | generic/tclDate.c | 9 | ||||
-rw-r--r-- | generic/tclGetDate.y | 9 | ||||
-rw-r--r-- | tests/clock.test | 8 |
4 files changed, 31 insertions, 4 deletions
diff --git a/generic/tclClockFmt.c b/generic/tclClockFmt.c index c216d34..66dbf6b 100644 --- a/generic/tclClockFmt.c +++ b/generic/tclClockFmt.c @@ -56,6 +56,11 @@ static void ClockFrmScnFinalize(void *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, @@ -113,6 +118,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 1614bb0..10f2151 100644 --- a/generic/tclDate.c +++ b/generic/tclDate.c @@ -2499,6 +2499,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, @@ -2636,6 +2641,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 0bf16e8..b0a8f85 100644 --- a/generic/tclGetDate.y +++ b/generic/tclGetDate.y @@ -875,6 +875,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, @@ -1012,6 +1017,10 @@ TclDatelex( } while (Count > 0); } } + +#if defined(__GNUC__) || defined(__GNUG__) +# pragma GCC reset_options +#endif int TclClockFreeScan( diff --git a/tests/clock.test b/tests/clock.test index 4420534..2a3557c 100644 --- a/tests/clock.test +++ b/tests/clock.test @@ -18682,11 +18682,11 @@ test clock-6.8 {input of seconds} { clock scan {9223372036854775807} -format %s -gmt true } 9223372036854775807 -test clock-6.9 {input of seconds - overflow} knownBug { +test clock-6.9 {input of seconds - overflow} { list [catch {clock scan -9223372036854775809 -format %s -gmt true} result] $result $::errorCode } {1 {integer value too large to represent} {CLOCK dateTooLarge}} -test clock-6.10 {input of seconds - overflow} knownBug { +test clock-6.10 {input of seconds - overflow} { list [catch {clock scan 9223372036854775808 -format %s -gmt true} result] $result $::errorCode } {1 {integer value too large to represent} {CLOCK dateTooLarge}} @@ -36243,11 +36243,11 @@ test clock-34.16 {clock scan, ISO 8601 point in time format} { set time [clock scan "19921023T235959" -gmt true] clock format $time -format {%b %d, %Y %H:%M:%S} -gmt true } "Oct 23, 1992 23:59:59" -test clock-34.16.1a {clock scan, ISO 8601 T literal optional (YYYYMMDDhhmmss)} knownBug { +test clock-34.16.1a {clock scan, ISO 8601 T literal optional (YYYYMMDDhhmmss)} { set time [clock scan "19921023235959" -gmt true] clock format $time -format {%b %d, %Y %H:%M:%S} -gmt true } "Oct 23, 1992 23:59:59" -test clock-34.16.1b {clock scan, ISO 8601 T literal optional (YYYYMMDDhhmm)} knownBug { +test clock-34.16.1b {clock scan, ISO 8601 T literal optional (YYYYMMDDhhmm)} { set time [clock scan "199210232359" -gmt true] clock format $time -format {%b %d, %Y %H:%M:%S} -gmt true } "Oct 23, 1992 23:59:00" |