This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
(c++) enum bitfield + template operator problem
- To: egcs-bugs at egcs dot cygnus dot com
- Subject: (c++) enum bitfield + template operator problem
- From: Mumit Khan <khan at xraylith dot wisc dot EDU>
- Date: Tue, 20 Jul 1999 16:42:53 -0500
The following testcase shows a problem in handling enum bitfields in gcc.
template <class _Tp>
inline bool operator!=(const _Tp& __x, const _Tp& __y) {
return !(__x == __y);
}
struct a
{
enum status {bad = 0, good = 1};
status s:1;
bool ok () const { return s != bad; }
};
$ /usr/local/gcc-2.95/bin/gcc -c c++-bf-addr-bug.cc
c++-bf-addr-bug.cc: In method `bool a::ok() const':
c++-bf-addr-bug.cc:9: attempt to take address of bit-field structure member `a::s'
If I use an "int s:1" instead, gcc doesn't try to instantiate the
template operator and we're ok. In the case of the enum bitfield
where the template operator != is used, I believe that 9.6
[class.bit]/3 says that gcc needs to create a temporary to initialize
the function arguments.
Regards,
Mumit