Subject: A POSSIBLE BUG IN b17.1
From: [email-masked] (Tage Westlund)

18 Dec 1996 15:34:57 -0800
Sender: [email-masked]
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Reply-To: [email-masked]
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="------------25C35A6460E0"
X-Mailer: Mozilla 3.0 (Win95; I)
Original-To: [email-masked]
Original-CC: [email-masked]
Original-Sender: [email-masked]

This is a multi-part message in MIME format.

--------------25C35A6460E0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

See attachment!

--------------25C35A6460E0
Content-Type: text/plain; charset=us-ascii; name="Bugtest1.C"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="Bugtest1.C"

// A POSSIBLE BUG IN  gnu-win32-b17.1  when "freezing" the internal
// record   ostsstream filename.str()  
// 
// Reported by: [email-masked]
//
// This is a small subset of a well tested C++ program. It is coded
// in a Solaris 2.4 UNIX system environment.
// This program will fail when used in Win 95 using the new 
// Cygnus  gnu-win32-b17.1  binary package.
//
// After having ported the source code to the IBM-PC cloned
// computer, there were no compilation errors besides some
// trivial ones. But there was a runtime error with stack dump.
// It was easy to use "sprintf" instead of "filename.str()". Then
// the entire code was very well behaving in my PC.
//
// Since the following is a much reduced code, please do not find
// any meaning with it otherwise than to demonstrate a hang up
// in method LexBuild! 
//
// In my Solaris computer I got:
// % g++ -v
// gcc -v
// Reading specs from
// /usr/local/lib/gcc-lib/sparc-sun-solaris2.4/2.7.2/specs
// gcc version 2.7.2
//
// In my PC I got:
// % c++ -v
// - - - -
// gcc version cygnus-2.7.2-961023
//
// Execution in Solaris and in PC was wihout options:
// > g++ bugtest1.C
// > a.out       
// I passed this routine LexBuild successfully
// 
// Execution in PC gave:
// > c++ bugtest1.C
// > a.exe
// In cygwin_except_handler  Exception trapped!
// exception C0000005 at 401180
// exception: ax 0 bx 25BF3EC cx 25BF3EC dx 25BF3EC
// exception: si 5 di 100113BF bp 25BF3D4 sp 25BF340
// exception is: STATUS_ACCESS_VIOLATION
// Stack trace: - - - -   several lines
// In cygwin_except_handler
// Error while dumping state ( probably corrupted stack )
// 

#include <string.h>
#include <stream.h>
#include <iostream.h>
#include <fstream.h>
#include <strstream.h>
#include <iomanip.h>

// --------------------------------------------------------

class Lex {
public:
        Lex(int=2,int=4,int=50,char=' ');

        int LexBuild(Lex&,char*,int);
        Lex& putPos1(char ch){*pos1=ch; return *this;}
        Lex& putPos2(char ch){*pos2=ch; return *this;}
        Lex& forw1(){pos1++; return *this;}
        Lex& forw2(){pos2++; return *this;}

private:
        int item, row, col, siz;
        char bgr;
        char *beg, *pos1, *pos2, *ennd; // ...of array
        char *beg1, *beg2;
        char sysname[100];
        char blocksep,*pblsep;  // Block separator. Default #
        char pagesep,*ppagsep;  // Page separator. Default $
};
// --------------------------------------------------------
Lex::Lex(int itemx,int rowx,int colx,char bgrx){
        char *ptr;
        siz=itemx*rowx*colx;
        item=itemx; row=rowx; col=colx;
        bgr=bgrx;

        beg=new char[siz+1];
        pos1=pos2=beg1=beg2=beg;
        ennd=beg+siz;
        ptr=beg;
        pblsep=&blocksep; blocksep='#';
        ppagsep=&pagesep; pagesep='$';
        while(ptr != ennd)*ptr++=bgr; // set background char.
        *ptr='\0'; // end of string mark
}
// ----------------

int Lex::LexBuild(Lex& lexi,char *txt,int num) {
        ostrstream internal;  // Lippman, page 410.
        char *intptr=internal.str(); // "freeze" the internal record.
        char *aux1=txt;
        char *aux2=intptr;

        internal << num; // fill the record with num as alphabetic
                         // characters
        for(; *aux1 != '\0'; aux1++)lexi.putPos1(*aux1).forw1();
        for(; *aux2 != '\0'; aux2++)lexi.putPos2(*aux2).forw2();
//      lexi.nextRow();
        return 0;       
}
// ------------------------------------------------------------------

main(){

// Main parameter definitions:
        int lexcolumns=2;       // Lex: The number of columns in the
                                //      name to number lexicon
        int lexrows=200;        // Lex: Length (rows) of lexicon
        int lexwidth=20;        // Lex: The column width of lexicon
        char lexfill='`';       // Lex: The default fill of big string

        char text[100];
        int nr=1;

// INSTANTIATION Lex
        Lex arra(lexcolumns,lexrows,lexwidth,lexfill);

// Now I make the simplest possible call to the suspected method
// LexBuild above:

        arra.LexBuild(arra,text,nr++);
        
        cout << "I passed this routine LexBuild successfully\n";

        return 0;
}

--------------25C35A6460E0--

-
For help on using this list, send a message to
"[email-masked]" with one line of text: "help".