home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / turbo_c / bugs.zip / TC_BUG00.DOC < prev    next >
Text File  |  1987-06-18  |  21KB  |  678 lines

  1.  *****
  2.  
  3.    The following bugs were listed by Gene Alm on 14 June 1987.
  4.    As of this writing, they have NOT been reported to Frank
  5.    Borland by the reporter.  They will be reported within a day
  6.    or two.
  7.  
  8.    ***
  9.  
  10.       Error Class:  Error in math.h
  11.  
  12.       In the header file math.h, you will find:
  13.     
  14.         #define M_PI              3.14159265358979224
  15.   
  16.       This should read:
  17.   
  18.         #define M_PI              3.14159265358979324
  19.   
  20.       Reference:  Don Knuth, Seminumerical Algorithms
  21.   
  22.       Comments:  I have not checked any other values.  Are
  23.                  there any other dumb errors in these
  24.                  constants???
  25.  
  26.       Disposition:  Unreported
  27.   
  28.    ***
  29.  
  30.       Error Class:  Documentation error
  31.  
  32.         On page 144 of the Users Guide, there is an error in
  33.         the syntax shown for enumerated variables.  It reads:
  34.  
  35.           enum days = { Sun, Mon, Tues, Wed,
  36.                         Thurs, Fri, Sat };
  37.  
  38.         It should read:
  39.   
  40.           enum days { Sun, Mon, Tues, Wed,
  41.                         Thurs, Fri, Sat };
  42.  
  43.       Reference:  Lattice C Compiler Version 3.00 Technical
  44.                   Bulletin
  45.  
  46.       Comments:  The enum data type is quite a bit more flexible
  47.                  than implied in the illustration given.  Consult
  48.                  a good reference.
  49.  
  50.       Disposition:  Unreported
  51.  
  52.    ***
  53.  
  54.       Error Class:  Documentation error
  55.  
  56.         On page 297 of the Reference Guide, it states that the
  57.         -nxxx environment option sends the .OBJ and .ASM files
  58.         to the directory or path given in xxx.
  59.  
  60.         It ALSO sends load modules (.EXE) files to this path.
  61.  
  62.       Reference:  Try it and see!
  63.  
  64.       Comments:  I like to send temporary files (I usually
  65.                  consider .OBJ files as temporaries) to a ramdisk
  66.                  for speed but like to keep load modules on the
  67.                  current drive (hard disk).  The command line
  68.                  options by themselves don't seem to support
  69.                  sending .OBJ and .EXE files to different drives
  70.                  (paths).
  71.  
  72.       Disposition:  Unreported
  73.  
  74.    ***
  75.  
  76.       Error Class:  Documentation error
  77.  
  78.         On page 18 of the Reference Guide, the usage for _fmode
  79.         is shown as:
  80.  
  81.           extern int _fmode;
  82.  
  83.         If you look in the fcntl.h header file, you will discover
  84.         that the declaration is:
  85.  
  86.           extern unsigned _Cdecl _fmode;
  87.  
  88.         This confusion between an integer and an unsigned may
  89.         manifest itself in a warning message during compilation.  
  90.         
  91.       Reference:  See for yourself!
  92.  
  93.       Comments:  This is a common nuisance for a new product.
  94.                  The documentation doesn't agree with the facts.
  95.                  So assume the facts are correct.  Go with the
  96.                  declaration as shown in the header file since
  97.                  it is PROBABLY more current than the manual.
  98.  
  99.       Disposition:  Unreported
  100.  
  101.    ***
  102.  
  103.       Error class:  Compiler error
  104.  
  105.         If the following code is compiled, the compiler will return
  106.         a message that "code in line 9 has no effect."  Well
  107.         that is not true since if you execute the program the results
  108.         that are listed via the two printf statements are different.
  109.         The code does indeed have an effect.  Fortunately the compiler
  110.         ignores its own warning and generates the correct code for a
  111.         statement that it says is redundant.  The statement is
  112.         syntactically correct.  The leading asterisk indicates a
  113.         dereferencing that is not used and this appears to be the
  114.         problem that the compiler recoginzes.  Removing this asterisk
  115.         causes the message to disappear.  But in C, I am allowed to
  116.         do what I want to do even if it makes no sense!  The compiler
  117.         should issue a redundant operator message, not a redundant
  118.         code message!
  119.         
  120.         static int  a[] = {0, 1, 2, 3, 4};
  121.         static int  *p[] = {a, a+1, a+2, a+3, a+4};
  122.         static int  **pp;
  123.   
  124.         void main () {
  125.         
  126.           pp = p;
  127.           printf ("\n%10d%10d%10d", pp-p, *pp-a, **pp);
  128.           *++*pp;
  129.           printf ("\n%10d%10d%10d", pp-p, *pp-a, **pp);
  130.         }
  131.  
  132.         Reference:  Kernighan and Ritchie
  133.  
  134.         Comments:  When receiving a message such as "code is
  135.                    bad", just how much of it is bad?  If the compiler
  136.                    recognizes redundant operators or statements,
  137.                    it might well inform the programmer of the "find".
  138.                    Other compilers don't inform the user that a
  139.                    redundant construct has been used.  I am delighted
  140.                    that this environment tells me about it.  More
  141.                    often than not, such a message will indicate that
  142.                    there is a problem.  But don't simply say that code
  143.                    is bad.  
  144.  
  145.         Disposition:  Unreported
  146.  
  147.    ***
  148.  
  149.         Documentation error
  150.  
  151.           On page 78 of the Reference Guide, the usage for
  152.           farcoreleft is given as:
  153.   
  154.             long farcoreleft (void);
  155.  
  156.           In the alloc.h header file, the prototype is shown as:
  157.   
  158.             unsigned long _Cdecl farcoreleft(void);
  159.  
  160.         Reference:  See for yourself
  161.  
  162.         Comments:  Once again, if the documentation differs from
  163.                    the information given in a header file, assume
  164.                    that the header file contains the latest, and
  165.                    therefore the most correct information.
  166.   
  167.         Disposition:  Unreported
  168.  
  169.   ***
  170.  
  171.         Error class:  Compiler error
  172.  
  173.           When the following program is executed, you will get
  174.           two different results.  Casting values in the expression
  175.           for xr0 does not alter the situation.  
  176.  
  177.           #define   MAX_POINTS  16
  178.    
  179.           main () {
  180.    
  181.             int      points, index;
  182.             double   xr0, xr1;
  183.  
  184.             points = MAX_POINTS;
  185.             for (index = 0; index < points; index++) {
  186.               xr0 = 512.0 / MAX_POINTS * index;
  187.               xr1 = 512 / MAX_POINTS * index;
  188.               printf ("\n%20.6lf%20.6lf", xr0, xr1);
  189.             }
  190.           }
  191.  
  192.         Reference:  Kernighan and Ritchie
  193.  
  194.         Comments:  If the order of the terms in xr0 is changed
  195.                    (xr0 = 512.0 * index / MAX_POINTS), the results
  196.                    will change.  Since the order of the terms should
  197.                    make no difference, this is a serious bug.  Other
  198.                    compilers handle the above code with no problem.
  199.                    It appears as though the compiler doesn't like
  200.                    the appearance of two constants together.  If
  201.                    you suspect this problem, interchange the order
  202.                    of the terms.
  203.  
  204.         Disposition:  Unreported
  205.  
  206.    ***
  207.  
  208.    ******************************************************************
  209.  
  210.                  16 June 1987
  211.  
  212.       There are a plethora of bugs in the documentation relating
  213.       to the agreement between the RG (Reference Guide) and the
  214.       header files.  I looked at these and here are some of the
  215.       problems that I found.  Only the disagreements are stated:
  216.       the correct prototype (in some cases) is not clear.
  217.  
  218.  
  219.    ******************************************************************
  220.  
  221.    Page 15 of RG
  222.  
  223.       It says that extern char *sys_errlist [];
  224.       and          extern int sys_nerr;
  225.  
  226.       are in errno.h.  They are in stdlib.h, not errno.h.
  227.  
  228.    Page 19 of RG
  229.  
  230.       It says that extern unsigned int _psp;
  231.  
  232.       is in stdlib.h.  It is in dos.h, not stdlib.h.
  233.  
  234.    Page 27 of RG
  235.  
  236.       The prototype for setblock is shown as
  237.          int setblock (int set, int newsize);
  238.       It is shown in dos.h as
  239.          int _Cdecl setblock(unsigned segx, unsigned newsize);
  240.  
  241.    Page 45 of RG
  242.  
  243.       The prototype for brk is shown as
  244.          int brk (void *endds);
  245.       It is shown in alloc.h as
  246.          int _Cdecl brk(char *addr);
  247.  
  248.       The prototype for sbrk is shown as
  249.          char *sbrk (int incr);
  250.       It is shown in alloc.h as
  251.          void *_Cdecl sbrk(int incr);
  252.  
  253.    Page 46 of RG
  254.  
  255.       The prototype for bsearch is shown as
  256.          void *bsearch (void *key, void *base, int *nelem,
  257.                         int width, int (*fcmp)());
  258.  
  259.       It is shown in stdlib.h as
  260.          void *_Cdecl bsearch(void *key, void *base, int nelem,
  261.             int width, int _Cdecl (*fcmp)());
  262.  
  263.       The prototype for lfind is shown as
  264.          void *lfind (void *key, void *base, int *nelem,
  265.                       int width, int (*fcmp)());
  266.  
  267.       It is shown in stdlib.h as
  268.          void *_Cdecl lfind  (void *key, void *base, unsigned *num,
  269.             int width, int _Cdecl (*fcmp)());
  270.  
  271.       The prototype for lsearch is shown as
  272.          void *lsearch (void *key, void *base, int *nelem,
  273.                         int width, int (*fcmp)());
  274.  
  275.       It is shown in stdlib.h as
  276.          void *_Cdecl lsearch(void *key, void *base, unsigned *num,
  277.             int width, int _Cdecl (*fcmp)());
  278.  
  279.    Page 70 of RG
  280.  
  281.       The prototype for eof is shown as
  282.          int eof (int *handle);
  283.    
  284.       It is shown in io.h as
  285.          int _Cdecl eof(int handle);
  286.  
  287.    Page 78 of RG
  288.  
  289.       The prototype for farcoreleft is shown as
  290.          long farcoreleft (void);
  291.       It is shown in alloc.h as
  292.          unsigned long _Cdecl farcoreleft(void);
  293.  
  294.    Page 101 of RG
  295.  
  296.       The prototype for fread is shown as
  297.          int fread (void *ptr, int size, int nitems, FILE *stream);
  298.       It is shown in stdio.h as
  299.          int _Cdecl fread (void *ptr, unsigned size, unsigned n, FILE *fp);
  300.  
  301.       The prototype for fwrite is shown as
  302.          int fwrite (void *ptr, int size, int nitems, FILE *stream);
  303.       It is shown in stdio.h as
  304.          int _Cdecl fwrite(void *ptr, unsigned size, unsigned n, FILE *fp);
  305.  
  306.    Page 105 of RG
  307.  
  308.       The prototype for fstat is shown as
  309.          int fstat (char *handle, struct stat *buff)
  310.       It is shown in stat.h as
  311.          int  fstat (int fildes, struct stat *statbuf);
  312.  
  313.    Page 106 of RG
  314.  
  315.       The prototype for fwrite is discussed above with Page 101
  316.       of RG.
  317.  
  318.       It says that when using gcvt you should use the statement
  319.          #include <dos.h>
  320.       It should say that you should use the statement
  321.          #include <stdlib.h>
  322.  
  323.    Page 107 of RG
  324.  
  325.       The prototype for ungetch is shown as
  326.          int ungetch (int c);
  327.       It is shown in conio.h as
  328.          int _Cdecl ungetch(unsigned ch);
  329.  
  330.    Page 114 of RG
  331.  
  332.       The prototype for getdfree is shown as
  333.          void getdfree (int drive, struct dfree *dfreep);
  334.       It is shown in dos.h as
  335.          int _Cdecl getdfree(unsigned char drive, struct dfree *dtable);
  336.  
  337.    Page 117 of RG
  338.  
  339.       The prototype for getfat is shown as
  340.          void getfat (int drive, struct fatinfo *fatblkp);
  341.       It is shown in dos.h as
  342.          int _Cdecl getfat(unsigned char drive, struct fatinfo *dtable);
  343.  
  344.       The prototype for getfatd is shown as
  345.          void getfatd (struct fatinfo *fatblkp);
  346.       It is shown in dos.h as
  347.          int _Cdecl getfatd(struct fatinfo *dtable);
  348.  
  349.    Page 118 of RG
  350.  
  351.       The prototype for getftime is in io.h and not in dos.h
  352.       as indicated.
  353.  
  354.    Page 123 of RG
  355.  
  356.       The prototype for setverify is shown as
  357.          void setverify (int value);
  358.       It is shown in dos.h as
  359.          int _Cdecl setverify(int value);
  360.  
  361.    Page 125 of RG
  362.  
  363.       The prototype for hardretn is shown as
  364.          void hardretn (int errcode);
  365.       It is shown in dos.h as
  366.          int _Cdecl hardretn(int retn);
  367.  
  368.    Page 128 of RG
  369.  
  370.       The prototype for hardretn is discussed with page 125 of RG.
  371.  
  372.    Page 136 of RG
  373.  
  374.       The prototype for ioctl is shown as
  375.          int ioctl (int handle, int cmd [, int *argdx, int argcx]);
  376.       It is shown in io.h as
  377.          int _Cdecl ioctl(int handle, char func, ...);
  378.          /* optional 3rd and 4th args are: void * argdx, int argcx */
  379.  
  380.    Page 138 of RG
  381.  
  382.       The prototypes for is... are to be found in ctype.h, not
  383.       in io.h as stated.
  384.  
  385.    Page 141 of RG
  386.  
  387.       The prototype for keep is shown as
  388.          void keep (int status, int size);
  389.       It is shown in dos.h as
  390.          void _Cdecl keep(unsigned char status, unsigned size);
  391.  
  392.    Page 142 of RG
  393.  
  394.       The prototype for lfind is shown as
  395.          void *lfind (void *key, void *base, int *nelem
  396.                       int width, int (*fcmp)());
  397.       It is shown in stdlib.h as
  398.          void *_Cdecl lfind (void *key, void *base, unsigned *num,
  399.                  int width, int _Cdecl (*fcmp)());
  400.  
  401.    Page 146 of RG
  402.  
  403.       The discussion of lsearch is to be found with page 46
  404.       comments.
  405.  
  406.       The prototype for lseek is shown as
  407.          long lseek (int handle, long offset, int fromwhere);
  408.       It is shown in io.h as
  409.          long _Cdecl lseek(int handle, long offset, unsigned char kind);
  410.  
  411.    Page 154 of RG
  412.  
  413.       The prototype for memchr is shown as
  414.          void *memchr (void *s, char ch, unsigned n);
  415.       It is shown in mem.h as
  416.          void *_Cdecl memchr(void *s, unsigned char c, unsigned n);
  417.  
  418.       The prototype for memcmp is shown as
  419.          void *memcmp (void *s1, void *s2, unsigned n);
  420.       It is shown in mem.h as
  421.          int _Cdecl memcmp(void *s1, void *s2, unsigned n);
  422.  
  423.       The prototype for memset is shown as
  424.          void *memset (void *s, char ch, unsigned n);
  425.       It is shown in mem.h as
  426.          void *_Cdecl memccpy(void *dest, void *src, unsigned char c,
  427.                               unsigned n);
  428.  
  429.    Page 156 of RG
  430.  
  431.       MK_FP is implemented as a macro as shown in dos.h.  The
  432.       description for MK_FP given in the RG should note this.
  433.  
  434.    Page 158 of RG
  435.  
  436.       The prototype for movedata is shown as
  437.          void movedata (int segsrc, int offsrc, int segdest,
  438.                         int offdest, unsigned numbytes);
  439.       It is shown in mem.h as
  440.          void _Cdecl  movedata(unsigned srcseg, unsigned srcoff,
  441.             unsigned dstseg, unsigned dstoff, unsigned n);
  442.  
  443.    Page 159 of RG
  444.        
  445.       The prototype for setmem is shown as
  446.          void setmem (void *addr, int len, char value);
  447.       It is shown in mem.h as
  448.          void _Cdecl setmem(void *dest, unsigned length, char value);
  449.  
  450.    Page 160 of RG
  451.  
  452.       The prototype for _open is shown as
  453.          int _open (char *pathname, int access);
  454.       It is shown in io.h as
  455.          int _Cdecl _open (char *filename, unsigned oflags);
  456.  
  457.       The prototype for open is shown as
  458.          int open (char *pathname, int access [, int permiss]);
  459.       It is shown in io.h as
  460.          int _Cdecl open(char *path, unsigned access,...
  461.                          /*unsigned mode*/);
  462.  
  463.       For both of the above functions, be sure to #include <io.h>
  464.       to access the prototypes.
  465.  
  466.    Page 163 of RG
  467.  
  468.       The prototype for parsfnm is shown as
  469.          char *parsfnm (char *cmdline, struct fcb *fcbptr,
  470.                         int option);
  471.       It is shown in dos.h as
  472.          char *_Cdecl parsfnm(char *cmdline, struct fcb *fcb,
  473.                               unsigned char opt);
  474.  
  475.    Page 164 of RG
  476.  
  477.       The prototype for peek is shown as
  478.          char peek (int segment, unsigned offset);
  479.       It is shown in dos.h as
  480.          int _Cdecl peek(unsigned segment, unsigned offset);
  481.  
  482.       The prototype for peekb is shown as
  483.          char peekb (int segment, unsigned offset);
  484.       It is shown in dos.h as
  485.          int _Cdecl peekb(unsigned segment, unsigned offset);
  486.  
  487.    Page 166 of RG
  488.  
  489.       The prototype for poke is shown as
  490.          void poke (int segment, int offset, int value);
  491.       It is shown in dos.h as
  492.          void _Cdecl poke(unsigned segment, unsigned offset, int value);
  493.  
  494.       The prototype for pokeb is shown as
  495.          void pokeb (int segment, int offset, char value);
  496.       It is shown in dos.h as
  497.          void _Cdecl pokeb(unsigned segment, unsigned offset, char value);
  498.  
  499.    Page 168 of RG
  500.  
  501.       The cprintf function will be found in conio.h and not
  502.       in stdio.h.
  503.  
  504.    Page 181 of RG
  505.  
  506.       The prototype for fputc is shown as
  507.          int fputc (int ch, FILE *stream);
  508.       It is shown in stdio.h as
  509.          int _Cdecl fputc (char c, FILE *fp);
  510.  
  511.       The putch function will be found in conio.h and not
  512.       in stdio.h.
  513.  
  514.       The prototype for putw is shown as
  515.          int putw (int w, FILE *stream);
  516.       It is shown in stdio.h as
  517.          int _Cdecl putw (unsigned w, FILE *fp);
  518.  
  519.    Page 184 of RG
  520.  
  521.       The putw function is discusssed in the page 181 information.
  522.  
  523.    Page 185 of RG
  524.  
  525.       The prototype for qsort is shown as
  526.          void qsort (void *base, int nelem, int width,
  527.                      int (*fcmp)());
  528.       It is shown in stdlib.h as
  529.          void _Cdecl qsort  (void *base,
  530.               unsigned nelem,
  531.               unsigned width,
  532.               int _Cdecl (*fcmp)());
  533.  
  534.    Page 188 of RG
  535.  
  536.       The prototype for read is shown as
  537.          int read (int handle, void *buf, int nbyte);
  538.       It is shown in io.h as
  539.          int _Cdecl read (int handle, char *buf, unsigned int len);
  540.  
  541.    Page 190 of RG
  542.  
  543.       The prototype for rewind is shown as
  544.          int rewind (FILE *stream);
  545.       It is shown in stdio.h as
  546.          void _Cdecl rewind (FILE *fp);
  547.  
  548.    Page 191 of RG
  549.  
  550.       The discussion of sbrk is shown with that for page 45.
  551.  
  552.       The cscanf prototype is found in conio.h and not in
  553.       stdio.h.
  554.  
  555.    Page 205 of RG
  556.  
  557.       The discussion of setblock is shown with that for page 27.   
  558.  
  559.       The prototype for setbuf is shown as
  560.          void setbuf (FILE *stream, char *buf);
  561.       It is shown in io.h as
  562.          void _Cdecl setbuf (FILE *fp, void *buf);
  563.  
  564.       The prototype for setvbuf is shown as
  565.          int setvbuf (FILE *stream, char *buf, int type,
  566.                       unsigned size);
  567.       It is shown in io.h as
  568.          int _Cdecl setvbuf (FILE *stream, void *buf, int type,
  569.                              unsigned size);
  570.  
  571.    Page 209 of RG
  572.  
  573.       The discussion of setmem is shown with that for page 159.   
  574.       
  575.    Page 210 of RG
  576.  
  577.       The prototype for setmode is shown as
  578.          int setmode (int handle, unsigned mode);
  579.       It is shown in io.h as
  580.          int _Cdecl setmode (int handle, int amode);
  581.  
  582.    Page 211 of RG
  583.  
  584.       The discussion of setvbuf is shown with that for page 205.
  585.  
  586.       The discussion of setverify is shown with that for page 123.
  587.  
  588.    Page 212 of RG
  589.  
  590.       The prototype for sleep is shown as
  591.          unsigned sleep (unsigned seconds);
  592.       It is shown in dos.h as
  593.          void _Cdecl sleep(unsigned seconds);
  594.  
  595.    Page 221 of RG
  596.  
  597.       The discussion of fstat is shown with that for page 105.   
  598.    
  599.    
  600.    Page 224 of RG
  601.  
  602.       The prototype for strcspn is shown as
  603.          int strcspn (char *str1, char *str2);
  604.       It is shown in string.h as
  605.          size_t _Cdecl strcspn(char *s1, char *s2);
  606.  
  607.       The type size_t is typedef'd to be other than int.
  608.  
  609.       The prototype for strncat is shown as
  610.          char *strncat (char *destin, char *source, int maxlen);
  611.       It is shown in string.h as
  612.          char *_Cdecl strncat(char *dest, char *src, unsigned maxlen);
  613.  
  614.       The prototype for strncmp is shown as
  615.          int strncmp (char *str1, char *str2, int maxlen);
  616.       It is shown in string.h as
  617.          int _Cdecl strncmp(char *s1, char *s2, unsigned maxlen);
  618.  
  619.       The prototype for strncpy is shown as
  620.          char *strncpy (char *destin, char *source, int maxlen);
  621.       It is shown in string.h as
  622.          char *_Cdecl strncpy(char *dest, char *src, unsigned maxlen);
  623.  
  624.       The prototype for strspn is shown as
  625.          int strspn (char *str1, char *str2);
  626.       It is shown in string.h as
  627.          size_t    _Cdecl strspn(char *s1, char *s2);
  628.  
  629.       The prototypes for strtod and strtol were not to be found
  630.       in the appropriate header files (stdlib.h and string.h).
  631.  
  632.  
  633.    Page 234 of RG
  634.  
  635.       The prototype for swab is shown as
  636.          void swab (char *from, char *to, int nbytes);
  637.       It is shown in stdlib.h as
  638.          void _Cdecl swab (void *from, void *to, unsigned nbytes);
  639.  
  640.    Page 241 of RG
  641.  
  642.       The prototype for ungetc is shown as
  643.          int ungetc (char c, FILE *stream);
  644.       It is shown in stdio.h as
  645.          int _Cdecl ungetc (int c, FILE *fp);
  646.  
  647.    Page 243 of RG
  648.  
  649.       The prototype for unlock is given in io.h and not in
  650.       dos.h as shown.
  651.  
  652.    Page 249 of RG
  653.  
  654.       The prototype for write is shown as
  655.          int write (int handle, void *buf, int nbyte);
  656.       It is shown in io.h as
  657.          int _Cdecl write (int handle, char *buf, unsigned int len);
  658.  
  659.    
  660.  
  661.  
  662.    
  663.    
  664.  
  665.    
  666.  
  667.    
  668.          
  669.  
  670.  
  671.  
  672.  
  673.    
  674.       
  675.    
  676.  
  677.  
  678.