corrode icon indicating copy to clipboard operation
corrode copied to clipboard

Fails on global uninitialised structs

Open skade opened this issue 7 years ago • 2 comments

Consider the following C code:

typedef struct _test test;

struct _test {
   int test;
};

static test bar;

Corrode fails:

$ corrode uninitialized-global.c
("uninitialized-global.c": line 7): illegal initializer; check whether a real C compiler accepts this:
    { }

gcc accepts it:

$ gcc -c uninitialized-global.c -o test.o
$ echo $?
0

skade avatar Jul 04 '17 18:07 skade

I would be willing to provide a patch if I had a rough idea on where to look and to approach the problem. (I got the Rust experience and a bit of Haskell, but not the Corrode experience)

skade avatar Jul 04 '17 20:07 skade

https://github.com/jameysharp/corrode/blob/34053342c2f1ca04f23ad94d67057f14e74d9fb9/src/Language/Rust/Corrode/C.md#declarations i guess

try import Debug.Trace (trace) then expr <- trace ("faulty Ctype maybe? " ++ show ty) $ interpretInitializer ty (fromMaybe (CInitList [] node) minit)

flip111 avatar Nov 14 '17 23:11 flip111