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: C declarations Date: Mon, 30 Jan 2017 11:42:57 -0800 Organization: None to speak of Lines: 27 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="a9fae22b5f567322e337da4e19df7ab9"; logging-data="25319"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+rCtPb9tbLb7rmjUj39zk1" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:AQbKbeLBSydruGdCTCKm0TWwTS8= sha1:LgYJDLvyJlLwVFZDO0GNlkvo3YI= Xref: csiph.com comp.lang.c:102787 David Brown writes: > On 30/01/17 14:00, BartC wrote: [...] >> Then there is this, also outside a function, although more compilers >> complain about it: >> >> *p = 10; >> >> This presumably declares p to be of type int*, and initialises it to 10. > > Again, I believe it is legal syntax in C90. It has undefined behaviour > (due to the conversion from an integer). I believe it's legal syntax, but it's a constraint violation. There is no implicit conversion from int to int* (other than the special case of a null pointer constant). Pre-ANSI C compilers commonly permitted implicit conversions between pointers and integers, but C89/C90 did not. [...] -- 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"