From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6604 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] Add stdatomic.h for clang>=3.1 and gcc>=4.1 Date: Sun, 23 Nov 2014 11:37:19 -0500 Message-ID: <20141123163719.GK29621@brightrain.aerifal.cx> References: <386bdfe0.dNq.dMV.22.ce88IE@mailjet.com> <1415553117.2457.1250.camel@eris.loria.fr> <28e7e26d.dNq.dMV.24.cxrFKH@mailjet.com> <1416697795.16006.338.camel@eris.loria.fr> <20141122233022.GE29621@brightrain.aerifal.cx> <1416706295.16006.354.camel@eris.loria.fr> <20141123014354.GF29621@brightrain.aerifal.cx> <1416732543.16006.381.camel@eris.loria.fr> <20141123150639.GI29621@brightrain.aerifal.cx> <1416759497.16006.457.camel@eris.loria.fr> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1416760660 6827 80.91.229.3 (23 Nov 2014 16:37:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 23 Nov 2014 16:37:40 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-6617-gllmg-musl=m.gmane.org@lists.openwall.com Sun Nov 23 17:37:33 2014 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1XsaAH-0004l3-Cm for gllmg-musl@m.gmane.org; Sun, 23 Nov 2014 17:37:33 +0100 Original-Received: (qmail 26340 invoked by uid 550); 23 Nov 2014 16:37:32 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 26332 invoked from network); 23 Nov 2014 16:37:31 -0000 Content-Disposition: inline In-Reply-To: <1416759497.16006.457.camel@eris.loria.fr> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:6604 Archived-At: On Sun, Nov 23, 2014 at 05:18:17PM +0100, Jens Gustedt wrote: > > > > > > > What has all of this to do with VLA? I am lost. > > > > > > > > > > > > The operands of __typeof__ and sizeof get evaluated when they have VLA > > > > > > type. I think this is the problem. > > > > > > > > > > ah, ok > > > > > > > > > > No, this isn't a problem, I think. Arrays aren't allowed to be subject > > > > > of an _Atomic qualification (arrays are never qualified > > > > > themselves). For _Atomic type, the standard explicitly excludes > > > > > arrays. So arrays in general and VLA in particular should never be > > > > > passed as such into any of these generic functions, only pointers to > > > > > atomic objects can. > > > > > > > > Is a pointer to a variably modified type considered variably modified? > > > > > > yes > > > > > > > If so maybe these are affected too... > > > > > > no, the pointers that can be passed to the atomic "functions" are > > > always pointers to atomic objects, so they can't be arrays (and so > > > VLA) themselves, nor can an atomic struct containt a VLA or a pointer > > > to VLA. > > > > _Atomic int (*pmat)[n]; > > > > Then &pmat is a pointer to a valid atomic type, an atomic pointer to a > > VLA type. > > I don't see that. Ain't that a pointer to a VLA of base type _Atomic > int? > > The beast that you describe would be > > int (*_Atomic pmat)[n]; Yes, I messed it up. Sorry. > and effectively this would be an atomic pointer to VM type. But > concerning size, atomicity etc this is just a pointer type like any > other. (The size information doesn't change, once it is initialized.) > And concerning the atomic functions this is not different to > > int (*_Atomic pmat)[]; > > Could you describe a bit more, where you think that there is a problem > with such a thing? But it's a variably-modified type, so sizeof and typeof evaluate the expression when their operand is of this type. Thus, all you have to do is make an array of objects of this type, and then refer to arr[i++]. This will be an expression with variably-modified type, and the evaluation will have unwanted side effects. Rich