public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* RE: c++/2892
@ 2001-05-29 10:56 Ian Williams
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Williams @ 2001-05-29 10:56 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/2892; it has been noted by GNATS.

From: Ian Williams <ianw@sgi.com>
To: "'nathan@gcc.gnu.org'" <nathan@gcc.gnu.org>
Cc: gcc-gnats@gcc.gnu.org, Ian Williams <ianw@sgi.com>,
        Keith Seto
	 <keith@sgi.com>, nobody@gcc.gnu.org
Subject: RE: c++/2892
Date: Tue, 29 May 2001 10:54:02 -0700

 Apologies for replying all, however, i'm not sure how to replace the source
 file without creating a new bug so i've attached the corrected example
 program source at the bottom of this mail.
 
 (I think the original one got messed up as a result of some transfer to/from
 my Windows based mail system).
 
 Let me know if you would prefer me to send the program via another method.
 
 Thanks,
 
 Ian.
 
 
 -----Original Message-----
 From: nathan@gcc.gnu.org [ mailto:nathan@gcc.gnu.org ]
 Sent: Monday, May 28, 2001 3:15 AM
 To: gcc-gnats@gcc.gnu.org; ianw@sgi.com; keith@sgi.com;
 nobody@gcc.gnu.org
 Subject: Re: c++/2892
 
 
 Synopsis: array addresses corrupted when using template classes
 
 State-Changed-From-To: open->feedback
 State-Changed-By: nathan
 State-Changed-When: Mon May 28 03:14:57 2001
 State-Changed-Why:
     the sample code provided is full of strang \par things.
     please proved corrected sample code
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=2892&database=gcc
 
 
 
 
 
 --------------------------------------------------------------
 
 
 /*	Compile:        g++ -o test test.c++	*/
 
 #include <string.h>
 #include <iostream.h>
 #include <fstream.h>
 #include <stdlib.h>
 
 #ifndef TRUE
 #define TRUE    1
 #endif
 
 #ifndef FALSE
 #define FALSE   0
 #endif
 
 template <class T, class F> // T="To" the storage format for the buffer
                                 // F="From", the storage format from which
 the
                                 //           data comes
 
 
 class Buffer
 {
 public:
 
         Buffer(int length=100, char* label=NULL);
         virtual ~Buffer();
 
         virtual bool    add(F item) = 0;
         T*                      buf() const;
         int                     bufLength() const;
         bool                    canAddTo();
         void                    reset();
 
 protected:
 
         T*              mBuffer;
         int             mInBuffer;
 
 private:
 
         Buffer(const Buffer<T,F>& b);
 
         int     mBufferLength;
         bool    mOverflowReported;
         char*   mBufferName;
 };
 
 template <class T, class F>
 Buffer<T,F>::Buffer(int length, char* label) :
                 mBufferLength(length), mOverflowReported(FALSE),
                 mBuffer(NULL), mInBuffer(0), mBufferName(NULL)
 {
         mBuffer = new T[length];
         if (label != NULL)
         {
                 mBufferName = new char[strlen(label)+1];
                 strcpy(mBufferName,label);
         }
 }
 
 template <class T, class F>
 Buffer<T,F>::Buffer(const Buffer<T,F>& b) :
                 mBufferLength(0), mOverflowReported(FALSE),
                 mBuffer(NULL), mInBuffer(0), mBufferName(NULL)
 {
 }
 
 template <class T, class F>
 Buffer<T,F>::~Buffer()
 {
         if (mBuffer != NULL)
         {
                 delete [] mBuffer;
                 mBuffer = NULL;
                 mBufferLength = 0;
                 reset();
         }
         if (mBufferName != NULL)
         {
                 delete [] mBufferName;
                 mBufferName = NULL;
         }
 }
 
 template <class T, class F>
 T*
 Buffer<T,F>::buf() const
 {
         return mBuffer;
 }
 
 template <class T, class F>
 int
 Buffer<T,F>::bufLength() const
 {
         return mInBuffer;
 }
 
 template <class T, class F>
 bool
 Buffer<T,F>::canAddTo()
 {
         if ( mInBuffer == mBufferLength )
         {
                 if (!mOverflowReported)
                 {
                         mOverflowReported = TRUE;
                         if (mBufferName != NULL)
                                 cerr << mBufferName << ": ";
                         cerr << "Buffer overflow\n";
                 }
                 return FALSE;
         }
         return TRUE;
 }
 
 template <class T, class F>
 void
 Buffer<T,F>:: reset()
 {
         mOverflowReported = FALSE;
         mInBuffer = 0;
 }
 
 //////////////// Subclass for buffering arrays /////////////////////////////
 
 template <class T, class F>
 class BufferV : public Buffer<T,F>
 {
 public:
         BufferV(int length=100, char* label=NULL);
         virtual ~BufferV();
 
         virtual bool    add(F item);
 
 private:
         BufferV(const BufferV<T,F>& b);
 };
 
 template <class T, class F>
 BufferV<T,F>::BufferV(int length, char* label) : Buffer<T,F>(length,label)
 {
 }
 
 template <class T, class F>
 BufferV<T,F>::BufferV(const BufferV<T,F>& b) : Buffer<T,F>(b)
 {
 }
 
 template <class T, class F>
 BufferV<T,F>::~BufferV()
 {
 }
 
 template <class T, class F>
 bool
 BufferV<T,F>::add(F item)
 {
 
         cout    << "item = " << item[0] << ", " 
                 << item[1] << ", " << item[2] <<  endl;
 /*
         For some reason the following line yields the correct output
         when instantiated with F = int[3] or F = float[3]               
         cout    << "item = " << item[0+3] << ", " 
                 << item[1+3] << ", " << item[2+3] <<  endl;
 */
 
         if (Buffer<T,F>::canAddTo())
         {
                 cout << "mBuffer[" << mInBuffer << "] = ";
                 for (int i=0 ; i<3 ; i++) {
 /* 
         See above when instanciated with F = int[3] and float[3]        
                         mBuffer[mInBuffer][i] = item[i+3];
 */
                         mBuffer[mInBuffer][i] = item[i];
                         cout << mBuffer[mInBuffer][i] << ", ";
                 }
                 cout << endl;
                 mInBuffer++;
                 return TRUE;
         }
         return FALSE;
 }
 
 
 
 //typedef int  Dxyz[3],  *DxyzP;
 //typedef float  Dxyz[3],  *DxyzP;
 typedef double  Dxyz[3],  *DxyzP;
 
 static BufferV<Dxyz,Dxyz>       faceVertexBuf(10,"faceVertexBuf");
 
 Dxyz    input_points[4]={       {1.0, -1.0, 1.0},{1.0, 1.0, -1.0},
                                 {1.0, 1.0, 1.0},{1.0, -1.0, 1.0} };
 
 int main (int argc, char* argv[])
 {
         int i = 0, index;
         faceVertexBuf.reset();
 
         for (i=0;i<4; i++) {
 
                 index = faceVertexBuf.bufLength();
                 Dxyz    temp = {input_points[i][0], 
                                 input_points[i][1], 
                                 input_points[i][2]};
 
                 cout << "Input = " << temp[0] << ", " 
                      << temp[1] << ", " <<  temp[2] << endl; ;
 
                 faceVertexBuf.add(temp);
                 DxyzP tempP = faceVertexBuf.buf()[index];
 
                 cout << "Output = " << tempP[0] << ", " 
                      << tempP[1] << ", " <<  tempP[2] << endl; ;
 
         }
 
         return 0;
 }


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: c++/2892
@ 2001-08-20 14:16 Craig Rodrigues
  0 siblings, 0 replies; 4+ messages in thread
From: Craig Rodrigues @ 2001-08-20 14:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/2892; it has been noted by GNATS.

From: Craig Rodrigues <rodrigc@mediaone.net>
To: Joe Goyette <goyette@sgi.com>
Cc: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org
Subject: Re: c++/2892
Date: Mon, 20 Aug 2001 17:10:48 -0400

 On Mon, Aug 20, 2001 at 02:45:11PM -0500, Joe Goyette wrote:
 > Hi Nathan-
 > 
 > I wanted to send you a quick note and find out if you are still involved
 > with this bug fix request?  I noticed you were involved initially.  It
 > appears that the bug is now marked as "unassigned".
 > 
 > 
 > I have added an update to the case notes, and I am hoping someone can look
 > at the data, and help move the issue forward.  Any suggestions would be
 > greatly appreciated.
 > 
 > Thanks.
 > 
 > Joe
 > 
 > --
 > Joe Goyette
 > Systems Engineer
 > SGI - North Central Region
 > Phone:573.446.8600 Fax:573.447.2139


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: c++/2892
@ 2001-08-10  9:46 Joe Goyette
  0 siblings, 0 replies; 4+ messages in thread
From: Joe Goyette @ 2001-08-10  9:46 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/2892; it has been noted by GNATS.

From: "Joe Goyette" <goyette@sgi.com>
To: <gcc-gnats@gcc.gnu.org>,
	<gcc-prs@gcc.gnu.org>,
	<gcc-bugs@gcc.gnu.org>,
	<nobody@gcc.gnu.org>,
	<keith@sgi.com>,
	<rodrigc@gcc.gnu.org>,
	<nathan@gcc.gnu.org>,
	<ianw@sgi.com>
Cc:  
Subject: Re: c++/2892
Date: Fri, 10 Aug 2001 11:44:43 -0500

 The example case was compiled again, this time using CodeSourcery's Online
 Test Compilation to generate the executable.   The following output was
 generated. (the output was modified for readability)
 
 [goyette@tux tmp]$ ./test-cs
 Input = 		1, -1, 1
 item = 		4.93371e-270, 3.50301, -1.99882
 mBuffer[0] = 	4.93371e-270, 3.50301, -1.99882,
 Output = 	4.93371e-270, 3.50301, -1.99882
 Input = 		1, 1, -1
 item = 		4.93371e-270, 3.50301, -1.99882
 mBuffer[1] = 	4.93371e-270, 3.50301, -1.99882,
 Output = 	4.93371e-270, 3.50301, -1.99882
 Input = 		1, 1, 1
 item = 		4.93371e-270, 3.50301, -1.99882
 mBuffer[2] = 	4.93371e-270, 3.50301, -1.99882,
 Output = 	4.93371e-270, 3.50301, -1.99882
 Input = 		1, -1, 1
 item = 		4.93371e-270, 3.50301, -1.99882
 mBuffer[3] = 	4.93371e-270, 3.50301, -1.99882,
 Output = 	4.93371e-270, 3.50301, -1.99882
 
 
 These results are still incorrect.  The values in the item, mBuffer, and
 Output arrays should be identical to the corresponding Input array.
 
 
 Note:  Ian Williams (original submitter from SGI) is no longer working on
 this issue.  If possible, please add Joe Goyette (goyette@sgi.com) to the
 'cc list.
 
 Thanks. Joe.
 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: c++/2892
@ 2001-05-28  3:16 nathan
  0 siblings, 0 replies; 4+ messages in thread
From: nathan @ 2001-05-28  3:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/2892; it has been noted by GNATS.

From: nathan@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org, ianw@sgi.com, keith@sgi.com, nobody@gcc.gnu.org
Cc:  
Subject: Re: c++/2892
Date: 28 May 2001 10:14:58 -0000

 Synopsis: array addresses corrupted when using template classes
 
 State-Changed-From-To: open->feedback
 State-Changed-By: nathan
 State-Changed-When: Mon May 28 03:14:57 2001
 State-Changed-Why:
     the sample code provided is full of strang \par things.
     please proved corrected sample code
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=2892&database=gcc


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-08-20 14:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-29 10:56 c++/2892 Ian Williams
  -- strict thread matches above, loose matches on Subject: below --
2001-08-20 14:16 c++/2892 Craig Rodrigues
2001-08-10  9:46 c++/2892 Joe Goyette
2001-05-28  3:16 c++/2892 nathan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).