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]

g++ bug report - cannot use bit field as a function argument




Forgive me - my compiler is on a separate network so whatever I include
here I have to type by hand.

a) gcc version:

2.95.2 (w/libstdc++-2.90.7)

b) Commands given the compiler:

g++ -o test dummy.cpp

c) Type of machine:

Sparc Ultra1 running Solaris 2.5.1

d) Problem description:

A bit-field cannot be passed as a function argument.  An attempt to do so
with the following example source code yields this error message:

   attempt to take address of bit-field structure member 'S::b'
   in passing argument 1 of 'f(const bool&)'

e) Source code that produces the error:

struct S
{
   S( bool bb ) : b( bb ) {}
   bool b : 1;               // yes, a bit field
};

void f( const bool & b ) {}

int main()
{
   S s( true );

   f( bool( s.b ) );  // compiles if I explicitly create a temporary
   f( s.b );          // this causes the error msg

   return 0;
}



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