Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Tim Rentsch <txr@alumni.caltech.edu> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: ridiculous warning or not? |
| Date | 2012-09-07 19:17 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <kfn1uidfeci.fsf@x-alumni2.alumni.caltech.edu> (permalink) |
| References | <f87cd21e-eec8-4085-93c9-9315da17e455@googlegroups.com> <0.2721fc1ff3b8371a7969.20120821014136BST.87628d5b5r.fsf@bsb.me.uk> <lnharxhune.fsf@nuthaus.mib.org> <kfnsjatkh8z.fsf@x-alumni2.alumni.caltech.edu> <lnmx11sef3.fsf@nuthaus.mib.org> |
Keith Thompson <kst-u@mib.org> writes:
> Tim Rentsch <txr@alumni.caltech.edu> writes:
>> Keith Thompson <kst-u@mib.org> writes:
> [...snip-a-lot...]
>>> So this:
>>>
>>> char f[];
>>>
>>> is treated as:
>>>
>>> char f[] = 0;
>>
>> No, it would be 'char f[] = {0};' as the implementation is
>> obliged to do by 6.7.9p16 -- implementations are obliged to
>> follow "shall" directives.
>
> Implementations are obliged to follow *all* normative requirements
> in the standard. 6.9.2p2 requires an implicit "initializer equal
> to 0". I wouldn't say that `{0}` is "equal to 0".
>
>[...snip-some-more...]
>
>>> Apparently we have to interpret the "initializer equal to 0" to mean
>>> `{ 0 }` rather than `0` in this case. And we're supposed to infer
>>> from that that `f` has exactly one element; apparently `{ 0 }` is
>>> "equal to 0" but `{ 0, 0 }` isn't.
>>
>> { 0, 0 } is two initializers, not one.
>
> { 0, 0 } is one initializer, which contains two more initializers.
> [...snip elaboration...]
My comments were kind of half frivolous, because I find
it hard to believe someone would take this question so
seriously, when it seems perfectly obvious what is
intended. I do think my comments have some degree of
merit (and yours also), but not sufficient to overcome
the level of silliness present (for which I am more
to blame than you).
Therefore, rather than continuing on the particular
points above, I would like to quote from Defect Report #11
(slightly reformatted):
Question 3 Initialization of tentative definitions
---------------------------------------------------
If the file scope declaration
int i[10];
appears in a translation unit, subclause 6.7.2 suggests
that it is implicitly initialized as if
int i[10] = 0;
appears at the end of the translation unit. However, this
initializer is invalid, since subclause 6.5.7 prescribes
that the initializer for any object of array type must be
brace-enclosed. We believe that the intention of subclause
6.7.2 is that this declaration has an implicit initializer
of
int i[10] = {0};
Is this true?
Response
--------
Subclause 6.7.2 External object definitions contains the
following excerpt:
If a translation unit contains one or more tentative
definitions for an identifier, and the translation unit
contains no external definition for that identifier,
then the behavior is exactly as if the translation unit
contains a file scope declaration of that identifier,
with the composite type as of the end of the
translation unit, with an initializer equal to 0.
This statement describes an effect and not a literal token
sequence. Therefore, this example does not contain an
error.
Please note the first sentence in the last paragraph.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
ridiculous warning or not? kerravon <kerravon@w3.to> - 2012-08-20 02:41 -0700
Re: ridiculous warning or not? Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-08-20 07:55 -0400
Re: ridiculous warning or not? army1987 <army1987@ask-for-it.invalid> - 2012-08-20 19:11 +0000
Re: ridiculous warning or not? Kenneth Brody <kenbrody@spamcop.net> - 2012-08-20 16:09 -0400
Re: ridiculous warning or not? Tim Rentsch <txr@alumni.caltech.edu> - 2012-09-07 07:29 -0700
Re: ridiculous warning or not? Andrew Cooper <amc96@cam.ac.uk> - 2012-08-21 00:36 +0100
Re: ridiculous warning or not? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-08-21 01:41 +0100
Re: ridiculous warning or not? Keith Thompson <kst-u@mib.org> - 2012-08-20 18:59 -0700
Re: ridiculous warning or not? Tim Rentsch <txr@alumni.caltech.edu> - 2012-09-07 08:03 -0700
Re: ridiculous warning or not? Keith Thompson <kst-u@mib.org> - 2012-09-07 14:37 -0700
Re: ridiculous warning or not? Tim Rentsch <txr@alumni.caltech.edu> - 2012-09-07 19:17 -0700
Re: ridiculous warning or not? Keith Thompson <kst-u@mib.org> - 2012-09-07 19:56 -0700
Re: ridiculous warning or not? Tim Rentsch <txr@alumni.caltech.edu> - 2012-09-08 06:30 -0700
Re: ridiculous warning or not? Tim Rentsch <txr@alumni.caltech.edu> - 2012-09-07 07:57 -0700
Re: ridiculous warning or not? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-09-08 00:25 +0100
Re: ridiculous warning or not? Tim Rentsch <txr@alumni.caltech.edu> - 2012-09-07 18:58 -0700
Re: ridiculous warning or not? Keith Thompson <kst-u@mib.org> - 2012-09-07 19:26 -0700
Re: ridiculous warning or not? Tim Rentsch <txr@alumni.caltech.edu> - 2012-09-08 06:26 -0700
Re: ridiculous warning or not? Keith Thompson <kst-u@mib.org> - 2012-09-08 11:33 -0700
Re: ridiculous warning or not? Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-17 14:39 -0800
Re: ridiculous warning or not? Keith Thompson <kst-u@mib.org> - 2012-12-17 15:56 -0800
Re: ridiculous warning or not? Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-20 10:31 -0800
Re: ridiculous warning or not? Keith Thompson <kst-u@mib.org> - 2012-12-20 16:57 -0800
Re: ridiculous warning or not? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-12-21 03:11 +0000
Re: ridiculous warning or not? Tim Rentsch <txr@alumni.caltech.edu> - 2012-12-21 09:06 -0800
Re: ridiculous warning or not? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-09-08 03:42 +0100
Re: ridiculous warning or not? Tim Rentsch <txr@alumni.caltech.edu> - 2012-09-08 06:01 -0700
Re: ridiculous warning or not? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-09-08 14:45 +0100
Re: ridiculous warning or not? Keith Thompson <kst-u@mib.org> - 2012-09-08 11:28 -0700
Re: ridiculous warning or not? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-09-08 22:53 +0100
Re: ridiculous warning or not? kerravon <kerravon@w3.to> - 2012-08-21 03:25 -0700
Re: ridiculous warning or not? 88888 Dihedral <dihedral88888@googlemail.com> - 2012-08-21 11:20 -0700
Re: ridiculous warning or not? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-08-21 21:07 +0100
Re: ridiculous warning or not? 88888 Dihedral <dihedral88888@googlemail.com> - 2012-08-21 14:39 -0700
Re: ridiculous warning or not? Ike Naar <ike@iceland.freeshell.org> - 2012-08-21 22:09 +0000
Re: ridiculous warning or not? 88888 Dihedral <dihedral88888@googlemail.com> - 2012-08-21 15:13 -0700
Re: ridiculous warning or not? Fred K <fred.l.kleinschmidt@gmail.com> - 2012-08-22 07:17 -0700
csiph-web