Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 0f96bfcdaa8931b7be1adae43f0d786bc1de79d3
Ticket: 219196ffffffffffffffffffffffffffffffffff
size_t != unsigned int
User & Date: dkf on 2013-08-21 09:59:49
Changes

  1. closer changed to: "nobody"
  2. comment changed to:
    OriginalBugID: 2715 Bug
    Version: 8.2
    SubmitDate: '1999-09-10'
    LastModified: '2000-04-03'
    Severity: SER
    Status: Assigned
    Submitter: techsupp
    ChangedBy: hobbs
    OS: Digital Unix
    OSVersion: 4.0f
    Machine: Other
    FixedDate: '2000-10-25'
    ClosedDate: '2000-10-25'
    
    
    Name: Wolfgang S. Kechel
    
    ReproducibleScript:
    Many warnings and inconsistencies when compiling tcl8.2 with gcc-2.95
        under Compaq True Unix 4.0f (no threads).
        The problems are all related to 64/32 bit problems when allocating
        memory.
        All allocation problems should use long int for the size parameter.
        Additionally, stdio.h should be included in some different lines in some
        headers
        to make gcc-2.95 happy with varargs. Here is a summary of changes:
        
        generic/tclInt.h: move <tt>include <stdio.h></tt> behind the include
        command for tcl.h (some 5 lines down).
        
        generic/tcl.h: move <tt>include <stdio.h></tt> behind the include
        command for stdarg.h/varargs.h to avoid compilation warnings on some
        platforms
        (namely Compaq True Unix 4.0f with gcc-2.95).
        
        generic/tclCkalloc.c and generic/tclDecls.h: Change the
        prototype/signature for Tcl_Alloc and Tcl_Realloc to use <tt>unsigned
        long</tt> instead of <tt>unsigned int</tt>.
        
        generic/tclalloc.c and generic/tclIntDecls.h: Change the
        prototype/signature for TclpAlloc and TclpRealloc to use <tt>unsigned
        long</tt> instead of <tt>unsigned int</tt>.
        
        generic/tclAlloc.c, generic/tclInt.h: Change the if that checks aginat a
        returned NULL pointer to check against a malloced size of 0 as well and
        signal an error only when a NULL pointer is returned for a block of
        memory that is of non-zero size:<br> <tt>if (result == NULL &&
        size)</tt><br>This is around line 800 in the file.
    
    DesiredBehavior:
    Should compile with gcc-2.95 and -Wall -Wconversion without 
        warnings.
    
    Patch:
    diff tclInt.h /dv10/wke/g40/tcl8.2.0/generic
    30,31d29
    < #include <stdio.h>
    < 
    35a34,35
    > #include <stdio.h>
    > 
    1697c1697
    < EXTERN char *         TclpAlloc _ANSI_ARGS_((unsigned int size));
    ---
    > EXTERN char *         TclpAlloc _ANSI_ARGS_((unsigned long size));
    1742c1742
    <                           unsigned int size));
    ---
    >                           unsigned long size));
    118% diff tcl.h /dv10/wke/g40/tcl8.2.0/generic
    177,180d176
    < #ifndef BUFSIZ
    < #include <stdio.h>
    < #endif
    < 
    208a205,208
    > #endif
    > 
    > #ifndef BUFSIZ
    > #include <stdio.h>
    119% diff tclCkalloc.c /dv10/wke/g40/tcl8.2.0/generic
    566c566,567
    <     unsigned int size;
    ---
    > /*    unsigned int size;*/
    >     unsigned long size; /* changed by wke */
    581c582,583
    <     unsigned int size;
    ---
    > /*    unsigned int size;*/
    > unsigned long size; /* changed by wke */
    797c799,800
    <     unsigned int size;
    ---
    > /*    unsigned int size;*/
    >     unsigned long size; /* changed by wke */
    802c805
    <         if (result == NULL) 
    ---
    >         if (result == NULL && size) 
    839c842,843
    <     unsigned int size;
    ---
    > /*    unsigned int size;*/
    >     unsigned long size; /* changed by wke */
    120% diff tclAlloc.c /dv10/wke/g40/tcl8.2.0/generic
    246c246
    <     unsigned int nbytes;      /* Number of bytes to allocate. */
    ---
    >     unsigned long nbytes;     /* Number of bytes to allocate. */
    492c492
    <     unsigned int nbytes;      /* New size of memory. */
    ---
    >     unsigned long nbytes;     /* New size of memory. */
    664c664
    <     unsigned int nbytes;      /* Number of bytes to allocate. */
    ---
    >     unsigned long nbytes;     /* Number of bytes to allocate. */
    712c712
    <     unsigned int nbytes;      /* New size of memory. */
    ---
    >     unsigned long nbytes;     /* New size of memory. */
    121%
    
    PatchFiles:
    tclInt.h,tcl.h,tclCkalloc.c,tclAlloc.c
    
    
    
    The problem with alloc'ing 0 bytes was fixed in 8.2.1.  The other
    changes can't be made as provided, as they only apply to a small
    subset of platforms.  We may need to parameterize this. 
    -- 10/19/1999 hobbs
    
    This should really be using size_t's.  This may be a problem for
    non-ansi compilers if we change the headers in this way. 
    -- 04/03/2000 hobbs
    
  3. icomment:
    Formally, this isn't part of any particular subsystem; it's a cross-cutting issue.
    
  4. login: "dkf"
  5. mimetype: "text/x-fossil-wiki"
  6. priority changed to: "8"
  7. severity changed to: "Minor"
  8. subsystem changed to: "None"
  9. username: "dkf"