Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ike Naar <ike@sverige.freeshell.org> |
|---|---|
| Newsgroups | comp.std.c |
| Subject | Re: When is the complete type of an external definition known? |
| Date | 2012-08-20 12:27 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <slrn3vfsk34ba2.cu6.ike@sverige.freeshell.org> (permalink) |
| References | (2 earlier) <4c03f493-4606-4893-a3b6-291bd03152ff@googlegroups.com> <slrn3vfsk32o91.221.ike@iceland.freeshell.org> <fdc7ea7c-759a-4300-b396-36aad059fb58@googlegroups.com> <slrn3vfsk33kev.7o1.ike@sverige.freeshell.org> <61359da1-45c2-45cb-afac-1860d957ae79@googlegroups.com> |
On 2012-08-20, Vlad from Moscow <vlad.moscow@mail.ru> wrote:
> I do not like answers that starts with "I think' (without any offence).
> You think such a way others think aother way. Do we deal with a standard or not?
> Well, let change the original example the following way
>
> #include <stdio.h>
>
> int a[];
>
> int main( void )
> {
> printf( "sizeof( a ) = %ul\n", sizeof( a ) );
Nit: the format specifier to print an unsigned long is
"%lu", not "%ul". "%ul" will print an unsigned int, followed
by the letter "l".
> return ( 0 );
> }
>
> int a[10];
>
> Now there is no internal linkage. Where does the composite type of the
> array become known? What does the phrase of the standard "the behavior
> is exactly as if the translation unit contains a file scope
> declaration of that identifier, with the composite type" mean in this
> case? What is this mysterious behavior?
Before the first declaration, "a" is undeclared
and cannot be used in an expression.
Between the first and the second declarations,
"a" has an array type of unknown size, hence, an incomplete type,
so the occurrence if "sizeof a" at that point is an error.
The type of "a" is completed by the second declaration.
Both declarations serve as a tentative definition. Neither
of the declarations has an initializer, so there is no (explicit)
external definition; that is where 6.9.2 p2 applies, and an
(implicit) external definition as assumed. The type of this
external definition is the composite type of
the tentative definitions, with a zero initializer.
Back to comp.std.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
When is the complete type of an external definition known? Vlad from Moscow <vlad.moscow@mail.ru> - 2012-08-19 13:40 -0700
Re: When is the complete type of an external definition known? Keith Thompson <kst-u@mib.org> - 2012-08-19 14:06 -0700
Re: When is the complete type of an external definition known? Vlad from Moscow <vlad.moscow@mail.ru> - 2012-08-19 14:30 -0700
Re: When is the complete type of an external definition known? Ike Naar <ike@iceland.freeshell.org> - 2012-08-19 21:56 +0000
Re: When is the complete type of an external definition known? Vlad from Moscow <vlad.moscow@mail.ru> - 2012-08-19 16:42 -0700
Re: When is the complete type of an external definition known? Keith Thompson <kst-u@mib.org> - 2012-08-19 19:22 -0700
Re: When is the complete type of an external definition known? Wojtek Lerch <wojtek_l@yahoo.ca> - 2012-08-20 10:57 -0400
Re: When is the complete type of an external definition known? Keith Thompson <kst-u@mib.org> - 2012-08-20 13:01 -0700
Re: When is the complete type of an external definition known? Wojtek Lerch <wojtek_l@yahoo.ca> - 2012-08-20 16:58 -0400
Re: When is the complete type of an external definition known? pacman@kosh.dhis.org (Alan Curry) - 2012-08-21 00:44 +0000
Re: When is the complete type of an external definition known? Ike Naar <ike@sverige.freeshell.org> - 2012-08-20 05:57 +0000
Re: When is the complete type of an external definition known? Vlad from Moscow <vlad.moscow@mail.ru> - 2012-08-20 03:22 -0700
Re: When is the complete type of an external definition known? Ike Naar <ike@sverige.freeshell.org> - 2012-08-20 12:27 +0000
Re: When is the complete type of an external definition known? Jens Gustedt <jens.gustedt@loria.fr> - 2012-08-20 17:04 +0200
Re: When is the complete type of an external definition known? Ike Naar <ike@iceland.freeshell.org> - 2012-08-20 16:35 +0000
Re: When is the complete type of an external definition known? Jens Gustedt <jens.gustedt@loria.fr> - 2012-08-20 20:43 +0200
Re: When is the complete type of an external definition known? James Kuyper <jameskuyper@verizon.net> - 2012-08-20 08:46 -0400
Re: When is the complete type of an external definition known? Vlad from Moscow <vlad.moscow@mail.ru> - 2012-08-19 14:24 -0700
Re: When is the complete type of an external definition known? "Ersek, Laszlo" <lacos@caesar.elte.hu> - 2012-08-19 23:36 +0200
Re: When is the complete type of an external definition known? Vlad from Moscow <vlad.moscow@mail.ru> - 2012-08-19 14:46 -0700
csiph-web