Bugzilla – Bug 472
[cbackend] Static globals are prototyped as 'extern'
Last modified: 2004-12-03 11:20:26
You need to log in before you can comment on or make changes to this bug.
The C writer currently generates invalid C code (static followed by extern which will be an error in gcc-4.0, see also http://gcc.gnu.org/PR18799 ). For example: static char msg[] = "hello"; char *foo(void) { return msg; } gets translated into: /* Global Variable Declarations */ extern signed char l1__2E_msg_1[6]; /* Global Variable Definitions and Initialization */ static signed char l1__2E_msg_1[6] = "hello"; /* Function Bodies */ signed char *foo(void) { return (&(l1__2E_msg_1[0])); } A fix would be to emit a static forward declaration instead of extern. And even better - though this might not be easy - the static forward declaration should only be emitted if it is actually needed as they are invalid in C++.
Mine.
Fixed. Testcase here: http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20041129/021616.html Patch here: http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20041129/021617.html Thanks a lot for noticing this! -Chris