dbTalk Databases Forums  

Re: Query class derived from std::ostream constructor issue

mailing.database.mysql-plusplus mailing.database.mysql-plusplus


Discuss Re: Query class derived from std::ostream constructor issue in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Chris Frey
 
Posts: n/a

Default Re: Query class derived from std::ostream constructor issue - 11-20-2005 , 08:09 PM






On Thu, Nov 17, 2005 at 05:27:56PM -0500, Spinka, Kristofer wrote:
Quote:
Hi, I've noticed a serious bug that was introduced in
MySQL++ v2.0.0 when the Query class was changed to derive
from std:stream.

Per the C++ standard, regardless of the order of
statements in a constructor's initialization list, base
classes are initialized before the members of the current
class are.
Thanks for this bug report and patch! I believe this will affect the
ABI, so I'm waiting for Warren's comments.

I think a better way to handle this would be to use the protected
init() member. Regular streams like fstream and stringstream need to
behave the same way as our Query, since they need to controll their
own buf objects.

For example, they do (from g++ headers):

basic_ifstream()
: __istream_type(NULL), _M_filebuf()
{ this->init(&_M_filebuf); }

This would prevent a change in the ABI.

- Chris


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #2  
Old   
Chris Frey
 
Posts: n/a

Default Re: Query class derived from std::ostream constructor issue - 11-20-2005 , 09:37 PM






On Sun, Nov 20, 2005 at 09:08:50PM -0500, Chris Frey wrote:
Quote:
basic_ifstream()
: __istream_type(NULL), _M_filebuf()
{ this->init(&_M_filebuf); }
I've commited this style of fix to SVN. Please give it a test on your
platform.

- Chris


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #3  
Old   
Spinka, Kristofer
 
Posts: n/a

Default Re: Query class derived from std::ostream constructor issue - 11-22-2005 , 11:33 AM



That sounds like a much better way to manage the object
creation.

Nice!

/kristofer


Quote:
Thanks for this bug report and patch! I believe this will affect the
ABI, so I'm waiting for Warren's comments.

I think a better way to handle this would be to use the protected
init() member. Regular streams like fstream and stringstream need to
behave the same way as our Query, since they need to controll their
own buf objects.

For example, they do (from g++ headers):

basic_ifstream()
: __istream_type(NULL), _M_filebuf()
{ this->init(&_M_filebuf); }

This would prevent a change in the ABI.

- Chris
--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #4  
Old   
Warren Young
 
Posts: n/a

Default Re: Query class derived from std::ostream constructor issue - 11-23-2005 , 02:48 PM



Chris Frey wrote:
Quote:
On Sun, Nov 20, 2005 at 09:08:50PM -0500, Chris Frey wrote:

basic_ifstream()
: __istream_type(NULL), _M_filebuf()
{ this->init(&_M_filebuf); }

I've commited this style of fix to SVN. Please give it a test on your
platform.
Thanks for fixing this, Chris, and for reporting it, Kristofer.

The only problem with this change is that I prefer using 0 instead of
NULL, since they're guaranteed to be the same thing in C++, unlike in C.
Just an FYI for any future changes you might make.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #5  
Old   
Chris Frey
 
Posts: n/a

Default Re: Query class derived from std::ostream constructor issue - 11-23-2005 , 02:52 PM



On Wed, Nov 23, 2005 at 01:47:51PM -0700, Warren Young wrote:
Quote:
Chris Frey wrote:
On Sun, Nov 20, 2005 at 09:08:50PM -0500, Chris Frey wrote:

basic_ifstream()
: __istream_type(NULL), _M_filebuf()
{ this->init(&_M_filebuf); }

I've commited this style of fix to SVN. Please give it a test on your
platform.

Thanks for fixing this, Chris, and for reporting it, Kristofer.

The only problem with this change is that I prefer using 0 instead of
NULL, since they're guaranteed to be the same thing in C++, unlike in C.
Just an FYI for any future changes you might make.
I prefer 0 too, but I went with the gnu C++ library style this time.

- Chris


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.