From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16400 invoked by alias); 24 Sep 2004 02:35:06 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 16305 invoked from network); 24 Sep 2004 02:35:00 -0000 Received: from unknown (HELO merlin.cs.tamu.edu) (24.250.169.187) by sourceware.org with SMTP; 24 Sep 2004 02:35:00 -0000 Received: by merlin.cs.tamu.edu (Postfix, from userid 500) id 67E1B3558F; Thu, 23 Sep 2004 21:35:00 -0500 (CDT) To: "Giovanni Bajo" Cc: "Joseph S. Myers" , Subject: Re: attribute data structure rewrite References: <006d01c4a1dd$ffc60b70$dc4e2a97@bagio> From: Gabriel Dos Reis In-Reply-To: <006d01c4a1dd$ffc60b70$dc4e2a97@bagio> Organization: Texas A&M University, Department of Computer Science Date: Fri, 24 Sep 2004 02:59:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2004-09/txt/msg01393.txt.bz2 "Giovanni Bajo" writes: | Gabriel Dos Reis wrote: | | > Currently, the compiler fails on any of the following fails, | > complaining about non-"integral constant expression"-ness, which is | > pure nonense. | > | > const int N = 4; | > struct S { | > enum { M = 4 }; | > float x __attibute__((__aligned__(N))); | > float x __attibute__((__aligned__(M))); | > }; | > | > template | > struct buffer { | > typedef char U[sizeof(T)]; | > U data __attribute__((__aligned__(N))); | > }; | | Is there already a bug report about this? Hmm, now that you're questioning I think we don't have a proper PR for them. | Anothing thing I have been shown today is that we currently reject this: | | ---------------------------------------- | #include | #include | | struct A { char foo[10]; }; | | void bar(void) { | int i; | for (i=0;i<10;i++) | printf("%d\n", offsetof(struct A, foo[i])); | } | -------------------------------------- | | but we used to accept it. Any idea about its legality? Workarounds? My gut reaction is that "foo[i]" is not a data at compile-time location; so, it does not qualify for use in offsetof. We used to accept it because we did not implement offsetof correctly. For example, the following variation should be rejected (in C89 an C++ mode) struct A { char foo[10]; }; void bar(void) { int i; for (int i = 0; i < 10; ++i) { char ary[offsetof(struct A, foo[i] + 1); } } -- Gaby