|
2026-10-20
| ||
| 16:15 | • Closed ticket [e580d8372b]: clock scan: half-hour time zones (IST, NST, CAST, ... artifact: d0b7dbcc26 user: jan.nijtmans | |
|
2022-01-12
| ||
| 21:15 | • Closed ticket [da6f155ca4]: STRING_SIZE() macro: parenthesize numChars usage... artifact: 044b2a74da user: jan.nijtmans | |
| 16:33 | Fix [da6f155ca4]: STRING_SIZE() macro: parenthesize numChars usage. Fix more macro's like this. check-in: 2bb7cd72c8 user: jan.nijtmans tags: core-8-6-branch | |
|
2021-12-24
| ||
| 19:19 | • New ticket [da6f155ca4] STRING_SIZE() macro: parenthesize numChars usage. artifact: 0969894470 user: chrstphrchvz | |
STRING_SIZE() macro: parenthesize numChars usage
Closed / Fixedda6f155ca48c78c74eb40921ab3ac46a8cabc0afCreated 5 years agoUpdated 5 years ago
Descriptionwiki2021-12-24 19:19:54
I don’t observe anything broken due to the lack of parentheses around numChars in the STRING_SIZE() macro, but would it be a good idea to parenthesize it anyway to avoid surprises?
diff --git a/generic/tclStringRep.h b/generic/tclStringRep.h
index 25b854ea4..59e9499a7 100644
--- a/generic/tclStringRep.h
+++ b/generic/tclStringRep.h
@@ -67,7 +67,7 @@ typedef struct String {
#define STRING_MAXCHARS \
(int)(((size_t)UINT_MAX - 1 - TclOffset(String, unicode))/sizeof(Tcl_UniChar))
#define STRING_SIZE(numChars) \
- (TclOffset(String, unicode) + ((numChars + 1) * sizeof(Tcl_UniChar)))
+ (TclOffset(String, unicode) + (((numChars) + 1) * sizeof(Tcl_UniChar)))
#define stringCheckLimits(numChars) \
do { \
if ((numChars) < 0 || (numChars) > STRING_MAXCHARS) { \
Referenced by2
d0b7dbcc26Closed ticket [e580d8372b]: [clock scan]: half-hour time zones (IST, NST, CAST, …) are 30 minutes off since 8.6.13 plus 8 other changes ticket2026-10-20 16:15:112bb7cd72c8Fix [da6f155ca4]: STRING_SIZE() macro: parenthesize numChars usage. Fix more macro's like this. check-in2022-01-12 16:33:51
jan.nijtmanswiki2022-01-12 21:15:59
Fixed [here]. Thanks for the report and the patch. This same commit fixes other similar macro's too.
Log in (anonymous is fine) to add a comment.