Deutsch English Français Italiano |
<v2vq00$3fq60$2@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Thiago Adams <thiago.adams@gmail.com> Newsgroups: comp.lang.c Subject: Re: C23 auto x C++ auto. Date: Sun, 26 May 2024 14:02:56 -0300 Organization: A noiseless patient Spider Lines: 73 Message-ID: <v2vq00$3fq60$2@dont-email.me> References: <v2vela$3e4pn$1@dont-email.me> <20240526172307.00005e3e@yahoo.com> <v2viv9$3el3j$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sun, 26 May 2024 19:02:57 +0200 (CEST) Injection-Info: dont-email.me; posting-host="b36d0c53be6e431910f898a3cb57d404"; logging-data="3664064"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+W4Z+xIggfUDg/Aq/uskU/lM8OHQ+faJw=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:3nrgj2DjgfPJC5eGjAdOOD0vmRo= In-Reply-To: <v2viv9$3el3j$1@dont-email.me> Content-Language: en-GB Bytes: 2762 Em 5/26/2024 12:03 PM, Thiago Adams escreveu: > Em 5/26/2024 11:23 AM, Michael S escreveu: >> On Sun, 26 May 2024 10:49:30 -0300 >> Thiago Adams <thiago.adams@gmail.com> wrote: >> >>> I think most people is not aware of this: >>> >>> From 3096 C23 draft >>> >>> " >>> 6.7.9 Type inference >>> ... >>> 2 For such a declaration that is the definition of an object the >>> init- declarator shall have the form >>> >>> direct-declarator = assignment-expression >>> " >>> >>> Basically "direct-declarator" differs from "declarator" because it >>> does not contains pointer. >>> >>> Then the type inference using auto and pointer is something undefined >>> in C23. >>> >>> struct node{ >>> struct node * next; >>> >>> }; >>> int main(){ >>> struct node node = {}; >>> auto * p = node.next; >>> } >>> >>> <source>:7:4: error: 'auto' requires a plain identifier, possibly >>> with attributes, as declarator >>> 7 | auto * p = node.next; >>> | ^~~~ >>> >>> This differs from C++. >>> >>> >> >> Differs in positive way. Less confusing. >> > I agree! > > clang still accepts it. https://godbolt.org/z/nxhcWGo5h "For such a declaration that is the definition of an object the init-declarator shall have the form direct-declarator = assignment-expression ... 177) Implementations need not accept a direct declarator that is not of the form identifier attribute-specifier-sequence opt optionally enclosed in balanced pairs of parentheses; if a direct declarator of a different form is accepted, the behavior is implementation-defined. "