🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.os.ms-windows.programmer.win32
2 messages
2 total messages Started by Gary Edstrom Thu, 04 Apr 1996 22:14
BUG REPORT: Microsoft Visual C++ 4.1
#2113
Author: Gary Edstrom
Date: Thu, 04 Apr 1996 22:14
44 lines
1731 bytes
/* BugDemo.cpp

   Here is a demonstration of a serious bug that I just found in Microsoft
   Visual C++ Version 4.1. (The bug also exists in version 4.0).  When this
   program is compiled with all of the default options in the debug mode, the
   first of the two *= lines below fail to generate any code.  When compiled
   in the release mode, everything is OK.  The problem also goes away in the
   debug mode if you change the optimizations from "debug" to "compile for '
   speed".  Note that the only difference between the first and second 
   versions of the line is the use of a constant for the index rather than a 
   variable.

  This sample was created as a console application.
*/

#include <stdio.h>

struct {
    int a;
    int b;
    int c;
    int d;
    int e;
} X[1] = { 1,2,3,4,5 };

int main( void)
{

    int i = 0;

    X[i].a *= 2;  // <<<ERROR - No code generated in debug mode

    X[0].b *= 2; // This line works OK in either mode.

    printf( "a = %d, b = %d.\n", i, X[0].a, X[0].b );

    return 0;
}

--
Gary Edstrom <gbe@primenet.com> | Sequoia Software
PO Box 9573                     | Programming & Technical Services
Glendale CA 91226-0573          | PGP Key ID: 0x1A0D44BD
PGP Fingerprint: 72 AA 4F 73 05 53 89 C6  8A EE F4 EE D1 C0 13 8D 
Re: BUG REPORT: Microsoft Visual C++ 4.1
#2114
Author: Michael Furman
Date: Fri, 05 Apr 1996 14:09
36 lines
1860 bytes
In article <316445a3.428887193@news.primenet.com>, gbe@primenet.com 
says...
>
>/* BugDemo.cpp
>
>   Here is a demonstration of a serious bug that I just found in 
Microsoft
>   Visual C++ Version 4.1. 

Debugging version of MS C/C++ compilerss of all versions have bugs - 
I find them each time when I forget to set options for using optimizing
version. Last time it happend yesterday on the following code fragment
(r defined as "long", bcode as "unsigned char []", compiler version is
1.52):

  // Next statement must be compiled with enabled optimizations
  // because of bug in MSVC 1.52 C++ compiler  
  if((r & 0xFF) != bcode[7] || ((r >> 8) & 0xFF) != bcode[6] ||
     ((r >> 16)  & 0xFF) != bcode[5])
    return -1; 

Address of bcode[7] was calculated incorrectly - actually it used
bcode[5] instead.

My practice to avoid that is to use only optimizing version of compiler
(even in case of all disabled optimizations).

-- 
<<< If you received it by E-mail: it is a copy of post to the newsgroup 
>>>
---------------------------------------------------------------
Michael Furman,                       (603)893-1109
Geophysical Survey Systems, Inc.  fax:(603)889-3984
13 Klein Drive - P.O. Box 97          engr@gssi.mv.com 
North Salem, NH 03073-0097            71543.1334@compuserve.com
---------------------------------------------------------------
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads