LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 918 - c backend with array types can produce code rejected by gcc 4.0.1
Summary: c backend with array types can produce code rejected by gcc 4.0.1
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Backend: C (show other bugs)
Version: trunk
Hardware: All All
: P release blocker
Assignee: Unassigned LLVM Bugs
URL:
Keywords: compile-fail
Depends on:
Blocks:
 
Reported: 2006-09-20 13:55 PDT by Samuele Pedroni
Modified: 2018-11-07 00:17 PST (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments
.ll to reproduce the problem (309 bytes, text/plain)
2006-09-20 13:59 PDT, Samuele Pedroni
Details
test case for current llvm cvs head (221 bytes, text/plain)
2007-01-15 05:16 PST, Eric van Riet Paap
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Samuele Pedroni 2006-09-20 13:55:52 PDT
The C backend can currently (recent head) produce code with such patterns:

/* Global Declarations */
/* Structure forward decls */
struct l_structtype_s;

/* Typedefs */
typedef struct l_structtype_s l_fixarray_array3[3]; /* problematic 
declaration */
typedef struct l_structtype_s l_structtype_s;

/* Structure contents */
struct l_structtype_s {
  int field0;
};

gcc 4.0.1 will reject this with a "array type has incomplete element type" error.

this seems not valid C, precedently gcc accepted it as a (fragile) extension.
Comment 1 Samuele Pedroni 2006-09-20 13:59:40 PDT
Created attachment 396 [details]
.ll to reproduce the problem

I'm attaching an .ll file that produces such rejected c:

$ llvm-as -o ex.bc example.ll
$ llc -march=c -o ex.c ex.bc
$ gcc -c ex.c
ex.c:85: error: array type has incomplete element type
ex.c:98: warning: conflicting types for built-in function 'malloc'
$ gcc --version
i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5363)
Comment 2 Eric van Riet Paap 2007-01-11 04:18:01 PST
Could someone please have a look at this? This bug prefends PyPy from using the later gcc versions.
Comment 3 Chris Lattner 2007-01-11 18:02:38 PST
Eric, I'd love to see this fixed, but don't have bandwidth to investigate it.  I'd suggest making a call for help 
on the llvmdev list, you'll get more visibility there.
Comment 4 Eric van Riet Paap 2007-01-15 05:16:14 PST
Created attachment 564 [details]
test case for current llvm cvs head
Comment 5 Eric van Riet Paap 2007-01-15 05:16:58 PST
Comment on attachment 564 [details]
test case for current llvm cvs head

llvm-as -f testme.ll;llc -march=c -f testme.bc;gcc -c testme.cbe.c
Comment 6 Chris Lattner 2007-01-16 00:51:47 PST
Potential patch here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070115/042760.html
Comment 7 Gordon Henriksen 2007-01-16 01:02:13 PST
Rationale of patch is here:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2007-January/007804.html
Comment 8 Chris Lattner 2007-01-16 01:24:19 PST
Nice work, I applied Gordon's testcase here: 
Regression/CodeGen/CBackend/2007-01-15-NamedArrayType.ll

and here's a slightly adapted version of his patch:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070115/042762.html

Thanks Gordon!

-Chris
Comment 9 Eric van Riet Paap 2007-01-16 05:08:58 PST
great stuff! thank you Gordon and Chris!