This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: [c++] bug with new inlining mechanism on v-3,commentary
- To: gcc-bugs at gcc dot gnu dot org, mark at codesourcery dot com, nathan at cs dot bris dot ac dot uk, Gabriel dot Dos_Reis at sophia dot inria dot fr
- Subject: Re: [c++] bug with new inlining mechanism on v-3,commentary
- From: Benjamin Kosnik <bkoz at cygnus dot com>
- Date: Sun, 12 Dec 1999 13:40:20 -0800
Hmm. I'm no longer getting the ICE, which is nice. However, I am
getting different behavior between 2.95.2 and CVS egcs, where
egcs-2.95.2 is able to inline things that CVS egcs cannot (and, IMHO,
should.)
Testcase as below.
2.95.2 is able to inline this, and produces a nice, optimized function:
foo__FR8ios_base:
.LFB1:
pushl %ebp
.LCFI0:
movl %esp,%ebp
.LCFI1:
movl 8(%ebp),%edx
movl %ebp,%esp
movl (%edx),%eax
andl $-83985,%eax
orl $520,%eax
movl %eax,(%edx)
popl %ebp
ret
CVS egcs says:
%g++ -c mark01.cc -O2 -Winline -Werror
cc1plus: warnings being treated as errors
mark01.cc: In function `void foo (ios_base &)':
mark01.cc:15: warning: can't inline call to `_Ios_Fmtflags operator |
(_Ios_Fmtflags, _Ios_Fmtflags)'
mark01.cc:72: warning: called from here
?????
Again, some kind of elaborated diagnostic might be useful to the
end-user here.
best,
benjamin
------------------------test inline02.cc-------------------------------
// Build don't link:
// Copyright (C) 1999 Free Software Foundation, Inc.
// Special g++ Options: -ansi -pedantic-errors -O2 -Winline -Werror
// crash test - XFAIL *-*-*
namespace std {
// The following definitions of bitmask types are enums, not ints,
// as permitted (but not required) in the standard, in order to provide
// better type safety in iostream calls. A side effect is that
// expressions involving them are no longer compile-time constants.
enum _Ios_Fmtflags { _S_ios_fmtflags_end = 1<<18 };
inline _Ios_Fmtflags
operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
{ return _Ios_Fmtflags(static_cast<int>(__a) & static_cast<int>(__b)); }
inline _Ios_Fmtflags
operator|(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
{ return _Ios_Fmtflags(static_cast<int>(__a) | static_cast<int>(__b)); }
inline _Ios_Fmtflags
operator~(_Ios_Fmtflags __a)
{ return _Ios_Fmtflags(~static_cast<int>(__a)); }
// 27.4.2 Class ios_base
class ios_base
{
public:
// 27.4.2.1.2 Type ios_base::fmtflags
typedef _Ios_Fmtflags fmtflags;
// 27.4.2.1.2 Type fmtflags
// We use the bit values from libio.h if possible.
static const fmtflags boolalpha = fmtflags(1<<0);
static const fmtflags dec = fmtflags(1<<1);
static const fmtflags fixed = fmtflags(1<<2);
static const fmtflags hex = fmtflags(1<<3);
static const fmtflags internal = fmtflags(1<<4);
static const fmtflags left = fmtflags(1<<5);
static const fmtflags oct = fmtflags(1<<6);
static const fmtflags right = fmtflags(1<<7);
static const fmtflags scientific = fmtflags(1<<8);
static const fmtflags showbase = fmtflags(1<<9);
static const fmtflags showpoint = fmtflags(1<<10);
static const fmtflags showpos = fmtflags(1<<11);
static const fmtflags skipws = fmtflags(1<<12);
static const fmtflags unitbuf = fmtflags(1<<13);
static const fmtflags uppercase = fmtflags(1<<14);
static const fmtflags adjustfield = fmtflags(1<<15);
static const fmtflags basefield = fmtflags(1<<16);
static const fmtflags floatfield = fmtflags(1<<17);
protected:
// Data Members
fmtflags _M_flags;
public:
inline fmtflags
flags() const { return _M_flags; }
inline fmtflags
flags(fmtflags __fmtfl)
{
fmtflags __old = _M_flags;
_M_flags = __fmtfl;
return __old;
}
};
void
foo(ios_base& __io)
{
typedef ios_base::fmtflags fmtflags;
fmtflags __fmt = __io.flags();
fmtflags __fmtmask = ios_base::showpos | ios_base::basefield
| ios_base::uppercase | ios_base::internal;
fmtflags __fmtnew = ios_base::hex | ios_base::showbase;
__io.flags(__fmt & ~__fmtmask | __fmtnew);
}
} //std