This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[c++] parameter passing bug
- To: gcc-bugs at gcc dot gnu dot org, mark at codesourcery dot com, jason at cygnus dot com
- Subject: [c++] parameter passing bug
- From: Benjamin Kosnik <bkoz at redhat dot com>
- Date: Wed, 13 Dec 2000 17:06:14 -0800
The following small test case shows a bug with argument passing. I've
tried v3-abi and the old abi in current sources and both get it wrong:
(gdb) p c30
$1 = 32 ' '
yet inside the function gctype.is, c30 == -112
Breakpoint 1, main () at kill.cc:69
0x8090186 in std::ctype<char>::is (this=0x2e322e32, __m=space, __c=-112 '\220')
at kill.cc:62
(gdb) p __c
-benjamin
// 2000-12-13 bkoz
namespace std
{
struct ctype_base
{
// Non-standard typedefs.
typedef const int* __to_type;
enum mask
{
space = (1 << 8), // Whitespace
_M_ctype_base_mask_end = 1 << 12
};
};
template<typename _CharT>
// class __ctype_abstract_base : public locale::facet, public ctype_base
class __ctype_abstract_base : public ctype_base
{
public:
// Types:
typedef _CharT char_type;
bool
is(mask __m, char_type __c) const throw()
{ return this->do_is(__m, __c); }
protected:
virtual bool
do_is(mask __m, char_type __c) const throw() = 0;
};
template<typename _CharT>
class ctype : public __ctype_abstract_base<_CharT> {};
// 22.2.1.3 ctype specializations
template<>
class ctype<char> : public __ctype_abstract_base<char>
{
public:
// Types:
typedef char char_type;
inline bool
is(mask __m, char __c) const throw();
protected:
virtual bool
do_is(mask __m, char_type __c) const throw() { return true; }
};
bool
ctype<char>::is(mask __m, char __c) const throw()
{ return static_cast<mask>(__c) & __m; } // here __c != ' '
}
class gnu_ctype: public std::ctype<char> { };
int main()
{
char c30 = ' ';
gnu_ctype gctype;
bool test = gctype.is(std::ctype_base::space, c30); // step in here...
return 0;
}