Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 0969894470936a6ba15cc113edd285502469928f1feaa6106d8a8daf4a5c2ebe
Ticket: da6f155ca48c78c74eb40921ab3ac46a8cabc0af
STRING_SIZE() macro: parenthesize numChars usage
User & Date: chrstphrchvz on 2021-12-24 19:19:54
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    I don’t observe anything broken due to the lack of parentheses around <tt>numChars</tt> in the <tt>STRING_SIZE()</tt> macro, but would it be a good idea to parenthesize it anyway to avoid surprises?
    
    <pre>
    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) \
    <span style="color:red">-    (TclOffset(String, unicode) + ((numChars + 1) * sizeof(Tcl_UniChar)))</span>
    <span style="color:green">+    (TclOffset(String, unicode) + (((numChars) + 1) * sizeof(Tcl_UniChar)))</span>
     #define stringCheckLimits(numChars) \
         do {								\
     	if ((numChars) < 0 || (numChars) > STRING_MAXCHARS) {		\
    </pre>
    
  5. foundin changed to: "8.6.12"
  6. is_private changed to: "0"
  7. login: "chrstphrchvz"
  8. priority changed to: "5 Medium"
  9. resolution changed to: "None"
  10. severity changed to: "Cosmetic"
  11. status changed to: "Open"
  12. submitter changed to: "chrstphrchvz"
  13. subsystem changed to: "10. Objects"
  14. title changed to: "STRING_SIZE() macro: parenthesize numChars usage"
  15. type changed to: "Patch"