...
Wiki Markup |
---|
The storage for this object is either static (if the compound literal occurs at file scope) or automatic (if the compound literal occurs at block scope), and the storage duration is associated with its immediate enclosing block (\[[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\], Section 6.5.2.5.6). |
For example, in the following function
Code Block |
---|
void func(void) { int *ip = (int[4]){1,2,3,4}; /* ... */ } |
...
Wiki Markup |
---|
Note that only one object is created per compound literal \-\- even if the compound literal appears in a loop and has dynamic initializers (\[[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\], Section 6.5.2.5.16). |
This guideline recommendation is a specific instance of guideline rule DCL30-C. Declare objects with appropriate storage durations.
...
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
DCL21-C | low | unlikely | medium | P2 | L3 |
Bibliography
Related Guidelines
\[[ISO/IEC 9899:1999|https://www.securecoding.cert.org/confluence/display/seccode/AA.+References#AA.References-ISO%2FIEC98991999]\] Section 6.5.2.5 (Compound Literals) Wiki Markup
Bibliography
...
DCL20-C. Always specify void even if a function accepts no arguments 02. Declarations and Initialization (DCL)