This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
g++ bug report - cannot use bit field as a function argument
- To: gcc-bugs at gcc dot gnu dot org
- Subject: g++ bug report - cannot use bit field as a function argument
- From: "Ray S Gallimore" <rsga at eci dot esys dot com>
- Date: Thu, 9 Mar 2000 14:25:51 -0500
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;
}