...
Some compilers generate a diagnostic message when a pointer to an object with automatic storage duration is returned from a function, as in this example. Compile your Programmers should compile code at high warning levels and resolve any diagnostic messages (see MSC00-C. Compile cleanly at high warning levels).
...
| Code Block | ||||
|---|---|---|---|---|
| ||||
#include <stddef.h>
void init_array(char *array, size_t len) {
/* Initialize array */
return;
}
int main(int argc, char *argv[]void) {
char array[10];
init_array(array, sizeof(array) / sizeof(array[0]));
/* ... */
return 0;
}
|
...
| [Coverity 2007] | |
| [ISO/IEC 9899:2011] | 6.2.4, "Storage Durations of Objects" |