This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

(c++) enum bitfield + template operator problem


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]