- To: egcs-bugs-request at cygnus dot com
- Subject: Warning suppression in c++
- From: Klamer Schutte <Schutte at fel dot tno dot nl>
- Date: Mon, 25 May 1998 11:02:34 +0200
- Organization: TNO Physics and Electronics Laboratory
Hi,
The following code fragment:
> cat t.cc
#include <math.h>
#include <string>
gives the following warnings using egcs 1.0.3a on Linux x86:
> c++ -Wall -Wshadow -c -I. t.cc /usr/local/include/g++/std/bastring.h: In method `basic_string<charT,traits,Allocator>::basic_string(InputIterator, InputIterator)':
In file included from /usr/local/include/g++/string:6,
from t.cc:2:
/usr/local/include/g++/std/bastring.h:153: warning: declaration of `end'
shadows a member of `this'
/usr/local/include/g++/std/bastring.h:153: warning: declaration of
`begin' shadows a member of `this'
/usr/local/include/g++/std/bastring.h: In method `class
basic_string<charT,traits,Allocator> &
basic_string<charT,traits,Allocator>::replace(charT *, charT *,
InputIterator, InputIterator)':
/usr/local/include/g++/std/bastring.h:390: warning: declaration of `j1'
shadows global declaration
The attached patch clears these warnings (which are related to function
argument names in bastring.h already used for different things.)
Klamer
--
Klamer Schutte, E-mail: Schutte@fel.tno.nl
Electro-Optical Systems, TNO Physics and Electronics Laboratory
Tel: +31-70-3740469 -- Fax: +31-70-3740654 -- Home phone: +31-79-3423924
*** /usr/local/include/g++/std/bastring.h Fri May 22 10:30:40 1998
--- std/bastring.h Mon May 25 10:48:19 1998
***************
*** 146,156 ****
: dat (nilRep.grab ()) { assign (n, c); }
#ifdef __STL_MEMBER_TEMPLATES
template<class InputIterator>
! basic_string(InputIterator begin, InputIterator end)
#else
! basic_string(const_iterator begin, const_iterator end)
#endif
! : dat (nilRep.grab ()) { assign (begin, end); }
~basic_string ()
{ rep ()->release (); }
--- 146,156 ----
: dat (nilRep.grab ()) { assign (n, c); }
#ifdef __STL_MEMBER_TEMPLATES
template<class InputIterator>
! basic_string(InputIterator begin_, InputIterator end_)
#else
! basic_string(const_iterator begin_, const_iterator end_)
#endif
! : dat (nilRep.grab ()) { assign (begin_, end_); }
~basic_string ()
{ rep ()->release (); }
***************
*** 381,397 ****
#ifdef __STL_MEMBER_TEMPLATES
template <class charT, class traits, class Allocator> template <class InputIterator>
basic_string <charT, traits, Allocator>& basic_string <charT, traits, Allocator>::
! replace (iterator i1, iterator i2, InputIterator j1, InputIterator j2)
#else
template <class charT, class traits, class Allocator>
basic_string <charT, traits, Allocator>& basic_string <charT, traits, Allocator>::
! replace (iterator i1, iterator i2, const_iterator j1, const_iterator j2)
#endif
{
const size_type len = length ();
size_type pos = i1 - ibegin ();
size_type n1 = i2 - i1;
! size_type n2 = j2 - j1;
OUTOFRANGE (pos > len);
if (n1 > len - pos)
--- 381,397 ----
#ifdef __STL_MEMBER_TEMPLATES
template <class charT, class traits, class Allocator> template <class InputIterator>
basic_string <charT, traits, Allocator>& basic_string <charT, traits, Allocator>::
! replace (iterator i1, iterator i2, InputIterator j_1, InputIterator j2)
#else
template <class charT, class traits, class Allocator>
basic_string <charT, traits, Allocator>& basic_string <charT, traits, Allocator>::
! replace (iterator i1, iterator i2, const_iterator j_1, const_iterator j2)
#endif
{
const size_type len = length ();
size_type pos = i1 - ibegin ();
size_type n1 = i2 - i1;
! size_type n2 = j2 - j_1;
OUTOFRANGE (pos > len);
if (n1 > len - pos)
***************
*** 404,418 ****
Rep *p = Rep::create (newlen);
p->copy (0, data (), pos);
p->copy (pos + n2, data () + pos + n1, len - (pos + n1));
! for (; j1 != j2; ++j1, ++pos)
! traits::assign ((*p)[pos], *j1);
repup (p);
}
else
{
rep ()->move (pos + n2, data () + pos + n1, len - (pos + n1));
! for (; j1 != j2; ++j1, ++pos)
! traits::assign ((*rep ())[pos], *j1);
}
rep ()->len = newlen;
--- 404,418 ----
Rep *p = Rep::create (newlen);
p->copy (0, data (), pos);
p->copy (pos + n2, data () + pos + n1, len - (pos + n1));
! for (; j_1 != j2; ++j_1, ++pos)
! traits::assign ((*p)[pos], *j_1);
repup (p);
}
else
{
rep ()->move (pos + n2, data () + pos + n1, len - (pos + n1));
! for (; j_1 != j2; ++j_1, ++pos)
! traits::assign ((*rep ())[pos], *j_1);
}
rep ()->len = newlen;