From owner-freebsd-current@FreeBSD.ORG Tue Sep 7 20:32:33 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 159A816A4CE for ; Tue, 7 Sep 2004 20:32:33 +0000 (GMT) Received: from possum.icir.org (possum.icir.org [192.150.187.67]) by mx1.FreeBSD.org (Postfix) with ESMTP id 009A343D45 for ; Tue, 7 Sep 2004 20:32:33 +0000 (GMT) (envelope-from pavlin@icir.org) Received: from possum.icir.org (localhost [127.0.0.1]) by possum.icir.org (8.12.9p1/8.12.8) with ESMTP id i87KWVwK035940; Tue, 7 Sep 2004 13:32:31 -0700 (PDT) (envelope-from pavlin@possum.icir.org) Message-Id: <200409072032.i87KWVwK035940@possum.icir.org> To: Craig Rodrigues In-Reply-To: Message from Craig Rodrigues <20040907122542.GA17809@crodrigues.org> Date: Tue, 07 Sep 2004 13:32:31 -0700 From: Pavlin Radoslavov X-Mailman-Approved-At: Wed, 08 Sep 2004 11:41:53 +0000 cc: freebsd-current@freebsd.org cc: Pavlin Radoslavov Subject: Re: g++ may fail to compile __packed structures X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Sep 2004 20:32:33 -0000 > 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@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 Yes, I am aware of that patch (when I did some search on the subject before posting my email). However, again, when I use the vanilla g++ 3.4.1 which is 2 months old, or even the vanilla 3.4.2 which was just released today, I don't get the compilation error. Hence, why the disparity between the vanilla gcc and the lastest gcc that comes with FreeBSD? > 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 The above URL doesn't say anything about packed fields. Please correct me if I am wrong, but I think that __packed is not part of the C or C++ standart, hence this leaves some gray area for interpretation. Anyway, this is a subject for the gcc ML... However, I am trying to find-out why the FreeBSD gcc behaves different from the vanilla gcc, and which compiler has the "right" behavior. Thanks, Pavlin > > > 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@crodrigues.org