[LLVMbugs] [Bug 485] NEW: C writer generates invalid C code (zero-sized arrays)

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Dec 15 13:37:00 PST 2004


http://llvm.cs.uiuc.edu/bugs/show_bug.cgi?id=485

           Summary: C writer generates invalid C code (zero-sized arrays)
           Product: libraries
           Version: 1.4
          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 sometimes generates invalid C code (zero-sized arrays),
but this might actually be a frontend issue.

Consider this code:

struct Foo
{
    bool t;
    Foo() : t(false) { }
};

Foo* bar(int n)
{
    return new Foo[n];
}

Which gets translated into something like:

[...]
/* Function Bodies */

struct l_struct_2E_Foo *_Z3bari(int l1_n) {
  unsigned l2_tmp_2E_2;
  signed char *l3_tmp_2E_0;
  struct l_struct_2E_Foo (*l4_tmp_2E_3)[0];
  unsigned l2_indvar;
  unsigned l2_indvar__PHI_TEMPORARY;
  unsigned l2_indvar_2E_next;

  l2_tmp_2E_2 = (unsigned )l1_n;
  l3_tmp_2E_0 = _Znaj(l2_tmp_2E_2);
  l4_tmp_2E_3 = (struct l_struct_2E_Foo (*)[0])l3_tmp_2E_0;
[...]
 

The type of (and the cast to) l4_tmp_2E_3 is not valid C.

Thanks,
Markus



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