home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 14 Text / 14-Text.zip / C6_BUGS.ZIP / C6_20080.BUG < prev    next >
Text File  |  1990-09-11  |  2KB  |  57 lines

  1. Q64789 _outtext Can Produce Protection Violation Error
  2. Microsoft C Compiler (C)
  3. 6.00
  4. OS/2
  5.  
  6. Summary:
  7.  
  8. Under certain conditions, the C 6.00 version of _outtext can produce a
  9. protection violation. The error occurs when executing protected-mode
  10. programs compiled under the large and compact memory models. The
  11. following sample code illustrates the problem:
  12.  
  13. Sample Code:
  14.  
  15. /* Compile with any optimizations in large or compact model... */
  16.  
  17. #include <stdio.h>
  18. #include <graph.h>
  19. #include <conio.h>
  20.  
  21. char a1[10] = "boogie";
  22. char a2[10];
  23.  
  24. void main(void)
  25. {
  26.    _outtext(a1);        // This _outtext works correctly
  27.    a2[0] = 'a';
  28.    a2[1] = 'b';         // Construct a null-terminated string
  29.    a2[2] = '\0';
  30.    _outtext(a2);        // Segmentation Violation occurs here
  31. }
  32.  
  33. More Information:
  34.  
  35. Three methods of working around this problem are listed below:
  36.  
  37. 1. Initialize the string (that is, char a2[10] = "\0";).
  38.  
  39. 2. Declare the string variable as a local variable rather than as a
  40.    global variable.
  41.  
  42. 3. Increase the number of elements in the character array. In the
  43.    large memory model, arrays in the range of 649 to 5,000 bytes in
  44.    size will work without problems. Arrays containing 643 to 5,000
  45.    bytes will work when compiling under the compact memory model.
  46.    (Arrays larger than 5,000 bytes may work also; however, this has
  47.    not been tested.)
  48.  
  49. Microsoft has confirmed this to be a problem with C version 6.00. We
  50. are researching this problem and will post new information here as it
  51. becomes available.
  52.  
  53. Keywords:  buglist6.00
  54.  
  55. COPYRIGHT Microsoft Corporation, 1990.
  56. Updated  90/08/16 11:16
  57.