On Mon, Sep 06, 2004 at 01:24:15PM -0700, Pavlin Radoslavov wrote: > It appears that the lastest g++ compiler that comes with FreeBSD may > fail to compile a __packed structure when one of its fields is > passed by reference. At the end of this email is a sample program > that demonstrates the problem. The compilation error is: > > pavlin_at_carp[14] g++34 test.cc > test.cc: In function `int main()': > test.cc:22: error: cannot bind packed field `f1.foo::f' to `int&' > Exit 1 > > The problem appears to exist only with the recent g++ compiler that > comes with FreeBSD: This change was made recently to gcc: http://gcc.gnu.org/ml/gcc-patches/2003-07/msg01664.html Apparently in C++, you are not allowed to have non-const references to packed fields. See: http://www.comnets.rwth-aachen.de/doc/c++std/decl.html#dcl.init.ref Your testcase will compile if you change your copy_out function to: void copy_out(const int& i) { // i = 0x11223344; } but your testcase will not be too useful. You might want to follow up on one of the GCC mailing lists. -- Craig Rodrigues http://crodrigues.org rodrigc_at_crodrigues.orgReceived on Tue Sep 07 2004 - 10:25:42 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:10 UTC