This is the mail archive of the gcc-help@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]
Other format: [Raw text]

cannot bind packed field error


Hi,

compiling the following code with GCC 4.1 I get an error.

struct A {
  union {
    int  c;
  } b;
} __attribute__ ((packed));

void func(int const &) {}
void func(int &) {}

int main()
{
   A a;

   func(a.b.c);
}

Here is the error:

test.C:13: error: cannot bind packed field 'a.A::b.A::<anonymous union>::c' 
to'int&'

GCC 3.4.4, GCC 4.0.2 and Intel's compiler compile this code without an error, 
but version 4.1 gives me the error. 

Is this an error in the compiler or is there a mistake in the code?

I expect, that if the compiler really is not able to bind the value to an 
int&, then it tries to bind the value to int const & as this is done with 
temporaries for example.

Greetings
Christoph Bartoschek


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