Closed daniel-j closed 3 months ago
Is this a new change? The existing system has worked great before. Although I agree that this incompleteStruct
is probably cleaner anyways
This isn't a new change. This has caused me some headache trying to find out what is crashing the Nim compiler, turns out it was generic object types (distinct object shouldn't be used as concrete type). I don't have reproducible example, my code is multiple files and 500 lines long when the bug appeared. After compiling Nim compiler in debug mode I could get a stack trace which pointed me to the distinct object ending up unexpectedly.
Not quite sure why GitHub didn't detect it, but I merged this manually after testing locally that it worked.
Ref.: https://github.com/PMunch/futhark/commit/6a89adf444acf6847dc487f44d9e98c4983aa926
Hmm, after further testing this seems like the wrong fix. What works is a plain object without incompleteStruct pragma.
ptr distinct object
for example is invalid and can crash Nim compiler. It should be invalid codegen. UsingincompleteStruct
because empty structs have zero size in C. The actual struct implementation is usually in the .c file (private members in a way).