[LLVMbugs] [Bug 472] NEW: C writer generates invalid C code

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Fri Dec 3 09:11:41 PST 2004


           Summary: C writer generates invalid C code
           Product: libraries
           Version: 1.3
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: C backend
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: markus at oberhumer.com

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++.

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

More information about the llvm-bugs mailing list