cannot bind packed field error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux