Deutsch English Français Italiano |
<v2vgj3$3eh79$1@raubtier-asyl.eternal-september.org> 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!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail From: Bonita Montero <Bonita.Montero@gmail.com> Newsgroups: comp.lang.c Subject: Re: C23 auto x C++ auto. Date: Sun, 26 May 2024 16:22:28 +0200 Organization: A noiseless patient Spider Lines: 44 Message-ID: <v2vgj3$3eh79$1@raubtier-asyl.eternal-september.org> References: <v2vela$3e4pn$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 16:22:27 +0200 (CEST) Injection-Info: raubtier-asyl.eternal-september.org; posting-host="861c1998cc926dd42c778978d59780b8"; logging-data="3622121"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/JaUQSl99uTKOIbdRZp1LZizvXoS0b47c=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:DHIcyKpqVLFntO0SmXUS+VaoXac= In-Reply-To: <v2vela$3e4pn$1@dont-email.me> Content-Language: de-DE Bytes: 2281 Am 26.05.2024 um 15:49 schrieb Thiago Adams: > 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++. > > I don't know what type inference in C is good for since the type names in C are usually short. If I have short typenames in C++ I don't use type inference. Type-inference makes sense to make such things shorter typename map<string, string>::const_iterator it = map.cbegin(); This doesn't happen in C.