www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/02/06/02:34:30

Message-ID: <696BA06B3A0FD211BAAD0060B0C4DD83ECA5C9@wntx.tabq.com>
From: Wayne Donovan <donovan AT tabq DOT com DOT au>
To: "'djgpp-workers AT delorie DOT com'" <djgpp-workers AT delorie DOT com>
Subject: Bug in DJGPP V2.03, Simple Error in STL, simple fix given
Date: Tue, 6 Feb 2001 17:33:46 +1000
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2650.21)
Reply-To: djgpp-workers AT delorie DOT com

There is a simple bug in the STL Libraries that are distributed with DJGPP
V2.03. It only appears depending on which compile time warnings are enabled.

======================

If only the "-Wall" compile warning is turned on, then when using the
<deque> header file, 

==== File: test.cpp ======================
#include <deque>

int main()
{
	deque<int> _queue;          // instantiate an empty queue

	_queue.push_back( 10 );		// add an element

	if( _queue.size() )		    // if any elements, delete 1st
element
	{
		deque<int>::iterator it = _queue.begin();

		_queue.erase( it );	    // STL ERROR HERE
	}

    return 1;
}

 Compiling: test.cpp
 In method `struct _Deque_iterator<int,int &,int *, 0>
deque<int,allocator<int>,0>::erase(_Deque_iterator<int,int &,int *,0>)':
 test.cpp(26) Error: instantiated from here
 c:/djgpp/lang/cxx/stl_deque.h(818) Warning:  comparison between signed and
unsigned
 There were some errors

==========================================
Simple Fix:

In c:/djgpp/lang/cxx/stl_deque.h, line 818  (Last updated in 1997 by Silicon
Graphics Computer Systems, Inc)

Replace:
	if( __index < (size() >> 1)) {
With:
	if( __index < static_cast<difference_type>(size() >> 1)) {

========================================

Hope this is of some help.

This bug probably also occurs more than once in this file.
========================================

Wayne Donovan
Network Systems - Gaming
phone  +61 7 38620317
e-mail <donovan AT tabq DOT com DOT au>
 


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019