home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / amiga / programm / 18039 < prev    next >
Encoding:
Text File  |  1993-01-01  |  3.4 KB  |  108 lines

  1. Path: sparky!uunet!amusing!lordbah
  2. From: lordbah@amusing.Bah.Rochester.NY.US (Jeff Van Epps)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: SAS C 5.10 bug?
  5. Followup-To: comp.sys.amiga.programmer
  6. Distribution: world
  7. Reply-To: lordbah@amusing.Bah.Rochester.NY.US
  8. References: 
  9. Message-ID: <lordbah.2g0t@amusing.Bah.Rochester.NY.US>
  10. Date: 1 Jan 93 09:08:07 EDT
  11. Organization: Bah's News Club
  12. Lines: 94
  13.  
  14. OK, here's that problem I mentioned earlier.  It compiled OK with the
  15. optimizer while I was running AmigaDOS 1.3, but fails now with 2.1.
  16. At least I firmly believe that it was OK under 1.3, but I can't/won't
  17. downgrade the machine to check it out now.
  18.  
  19. ====== code here ======
  20.  
  21. # include    <stdio.h>
  22.  
  23. # define    MAX_VARS            20
  24. # define    MAX_NAME_LEN        10
  25. # define    MAX_VALUE_LEN        80
  26.  
  27. static struct {
  28.     char        name[MAX_NAME_LEN+1];        /* name of variable */
  29.     char        value[MAX_VALUE_LEN+1];        /* its value */
  30.     } vars[MAX_VARS];
  31.  
  32. static int    n_vars = 0;
  33.  
  34. main()
  35. {
  36. int i;
  37. char tmp[10];
  38.  
  39. n_vars = 10;
  40. for(i=0;i<n_vars;i++)
  41.     {
  42.     sprintf( tmp, "name%d", i );
  43.     strcpy( vars[i].name, tmp );
  44.     sprintf( tmp, "value%d", i );
  45.     strcpy( vars[i].value, tmp );
  46.     }
  47. for(i=0;i<n_vars;i++)
  48.     printf("vars[%d].name '%s' value '%s'\n",i,vars[i].name,vars[i].value);
  49. }
  50.  
  51. ====== end of code ======
  52. ====== compile & run ====
  53.  
  54. [WB:Communications/UUCP.old/src/AmigaNews/Anews/ARN]: lc -L -O testme
  55. SAS/C Compiler V5.10 for AmigaDOS
  56. Copyright (C) 1990 SAS Institute, Inc. All Rights Reserved.
  57.  
  58. Compiling testme.c
  59. Optimizing
  60. Module size P=00000080 D=00000033 U=00000730
  61.  
  62. Total files: 1, Compiled OK: 1
  63. Linking testme
  64. Blink - Version 5.10
  65. Copyright (c) 1990 SAS Institute, Inc.  All Rights Reserved.
  66.  
  67.  
  68. BLINK Complete - Maximum code size = 9204 ($000023f4) bytes
  69.  
  70. Final output file size = 7088 ($00001bb0) bytes
  71. [WB:Communications/UUCP.old/src/AmigaNews/Anews/ARN]: testme
  72. vars[0].name 'name9' value 'value9'
  73. vars[1].name 'name9' value 'value9'
  74. vars[2].name 'name9' value 'value9'
  75. vars[3].name 'name9' value 'value9'
  76. vars[4].name 'name9' value 'value9'
  77. vars[5].name 'name9' value 'value9'
  78. vars[6].name 'name9' value 'value9'
  79. vars[7].name 'name9' value 'value9'
  80. vars[8].name 'name9' value 'value9'
  81. vars[9].name 'name9' value 'value9'
  82. [WB:Communications/UUCP.old/src/AmigaNews/Anews/ARN]:
  83.  
  84. ===== end of run =====
  85.  
  86. Now, I can't see anything wrong with this code, especially since it
  87. works fine without the optimizer.  I would guess that for some reason
  88. the optimizer can't see that the loop var is being referenced inside
  89. the loop.  This test program uses printf, the 'real' code I was working
  90. on uses strcmp inside the loop.  Perhaps the fact that these can both
  91. be "builtin" functions has something to do with it?  [But maybe not,
  92. I just recompiled with an #undef printf and got the same results.]
  93.  
  94. [For the curious: this is part of the BARN newsreader, *not* the ARN
  95. newsreader, despite the fact that I never changed the directory name
  96. when I changed the name of the program.]
  97.  
  98. BTW, this is cute.  I received the 6.0 upgrade offer on 12/29, and it
  99. says the pricing is valid until 12/31.  I called SAS and they were
  100. closed until 1/4.  So I tried to mail in the order, but someone/thing
  101. knocked over my mailbox so the mailman didn't pick up the outgoing
  102. mail, thus my order won't be postmarked until 1/2.  I guess I'll have
  103. to appeal to SAS when I get the bill :-]
  104.  
  105. --------------------------------------------------------------------
  106.     Jeff Van Epps    uunet!amusing!lordbah
  107.                      lordbah@amusing.Bah.Rochester.NY.US
  108.