Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: usecases of void foo(char **b) {} Date: Sun, 06 Nov 2016 18:12:38 -0800 Organization: None to speak of Lines: 55 Message-ID: References: <87twbmfzah.fsf@bsb.me.uk> <87fun6f1j4.fsf@bsb.me.uk> <877f8hgb0p.fsf@bsb.me.uk> <87eg2pedkx.fsf@bsb.me.uk> <87wpghcu23.fsf@bsb.me.uk> <877f8gx44n.fsf@bsb.me.uk> <878tswb89s.fsf@bsb.me.uk> <87wpgg9l8k.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="570d0cbd2577bddae9d37f5103556a5d"; logging-data="32518"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19yJt+ETVuWBBnsuzIBpqqF" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:2kAdEQELTy3C03mLsFqKaFyCgiI= sha1:3WPYayW3BwPU6kYn3swPpaY7dp8= Xref: csiph.com comp.lang.c:96009 Ben Bacarisse writes: > Keith Thompson writes: [...] >> It did change between N1570 and C11. The inclusion of _Alignof was >> an error in N1570. In fact, _Alignof, unlike sizeof, can only be >> applied to a parenthesized array type, not to an array expression. >> The published C11 standard corrected that error. (The reason for >> that gratuitous difference is another matter.) > > Ah, I wrote that precisely because I seem to remember something like > that. How odd. I don't suppose there's a C11 rationale that explains > why? I don't thing a C11 Rationale document exists (which is a pity). This was discussed on comp.std.c back in 2011. Larry Jones, who I'm fairly sure is an ISO C committee member, said: _Alignof came from C++, so you'd have to ask them. In a followup, I wrote: Well, C++ has "alignof", not "_Alignof", so it's already incompatible. (Well sort of; has an "alignof" macro.) I'm not sure why C++'s alignof can't be applied to an expression the way sizeof can, but I can speculate. I found a paper that appears to be an early design for the alignof feature: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1971.pdf In that version, the alignof operator took either a parenthesized type name or a parenthesized constant expression; in the latter case, alignof just returns the value of its operand. I haven't figured out what the point of that was, and it's been dropped from the latest C++ draft. ``alignof expr'' could have conflicted with that form; that may be why it was left out. That consideration doesn't apply to C (and probably doesn't apply to C++ either). I can't think of any good reason (other than lack of time and resources) not to have let _Alignof take an expression argument the way sizeof does. In any case, the inability to write `_Alignof expr` probably isn't that big a loss. It's just an odd minor inconsistency that has never actually inconvenienced me. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"