Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Using ternary and summing array
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Kaz Kylheku, post: 4393926"] Do you have some tools so you see what the size of a is in the translated object file? (Is it in the object file?) This might be a degenerate case which has no meaning due to a possible flaw in the standard. Under 6.9.2 we have this text: A declaration of an identifier for an object that has file scope without an initializer, and without a storage-class specifier or with the storage-class specifier static, constitutes a tentative definition. 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. But an array cannot have an initializer equal to 0: int a[] = 0; // invalid! The second example for this section states the intent: If at the end of the translation unit containing int i[]; the array i still has incomplete type, the implicit initializer causes it to have one element, which is set to zero on program startup. This would be the case if the implicit initializer were { 0 }. The intent is clear from the example, but for the text to bear it out, we have to believe that "an initializer equal to zero" refers to a specific choice of initializer such as { 0 }. I would avoid this situation, since only a non-normative example gives it a clear meaning. Compiler writers, however, should pay careful attention to examples and footnotes. What does your compiler do if, at the end of the translation unit, you add: int a[] = { 0 }; ? [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Using ternary and summing array
Top