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: Null pointer constant Date: Mon, 19 Jun 2017 12:34:42 -0700 Organization: None to speak of Lines: 34 Message-ID: References: <0-20170619174840@ram.dialup.fu-berlin.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="6cbb5d51c319bdfdc6c4f737cfea8267"; logging-data="11779"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/zfNzgDB0eQ+NJ0u2s1Ofh" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:j9NyLIisBPhw8VX9fmiWHnLbnSI= sha1:duSI7x5vZ2+LvWcIO2VJhjKzWYQ= Xref: csiph.com comp.lang.c:112619 ram@zedat.fu-berlin.de (Stefan Ram) writes: > ram@zedat.fu-berlin.de (Stefan Ram) writes: >>A null pointer constant has to be an integer constant >>expression. Or such an expression cast to void*. > The type of »0« is »int«. But it is kind of like a means > that can be used to initialize every scalar type without > a cast! > > int a = 0; > _Bool b = 0; > void( *f )() = 0; > void * p = 0; > float c = 0; > double x = 0; > ... > > , and we can also: > > char s[ 10 ] ={ 0 }; Yes, most of these depend on implicit conversions, either from one arithmetic type to another, or from a null pointer constant to a pointer type. The use of { 0 } as an initializer depends on any unspecified subcomponents being initialized implicitly. (Expanding on what you wrote, not disagreeing.) -- 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"