Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler error for extern "C" struct #478

Open
Martinsos opened this issue Apr 18, 2013 · 1 comment
Open

Compiler error for extern "C" struct #478

Martinsos opened this issue Apr 18, 2013 · 1 comment
Labels

Comments

@Martinsos
Copy link

simple.cpp:
#include "simple_ispc.h"
extern "C" struct Test {
int b;
};
int main() {
ispc::simple();
}

simple.ispc:
extern "C" struct Test;
export void simple() {
Test t;
}

compile command:
ispc simple.ispc -o simple_ispc.o -h simple_ispc.h

Error message:
func.cpp(423): FATAL ERROR: Function verificication failed


*** Please file a bug report at https://github.com/ispc/ispc/issues
*** (Including as much information as you can about how to reproduce this error).
*** You have apparently encountered a bug in the compiler that we'd like to fix!


main.cpp(204): FATAL ERROR: Unhandled signal sent to process; terminating.

ispc version: 1.3.0
machine: Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz

@dbabokin
Copy link
Collaborator

Here's the stack:
#0 0x00000037eac35935 in raise () from /lib64/libc.so.6
#1 0x00000037eac370e8 in abort () from /lib64/libc.so.6
#2 0x000000000058a1f2 in FatalError (file=0x1762b0b "func.cpp", line=439, message=0x1762dd0 "Function verificication failed") at util.cpp:451
#3 0x0000000000529252 in Function::GenerateIR (this=0x3100110) at func.cpp:439
#4 0x00000000004a35d7 in AST::GenerateIR (this=0x271a230) at ast.cpp:68
#5 0x000000000053913f in Module::CompileFile (this=0x271a6f0) at module.cpp:361
#6 0x00000000005403ce in Module::CompileAndOutput (srcFile=0x7fffffffd898 "simple.ispc", arch=0x0, cpu=0x0, target=0x0, generatePIC=false, outputType=Module::Object, outFileName=0x7fffffffd8a7 "simple_ispc.o",
headerFileName=0x7fffffffd8b8 "simple_ispc.h", includeFileName=0x0, depsFileName=0x0, hostStubFileName=0x0, devStubFileName=0x0) at module.cpp:2281
#7 0x0000000000537d9d in main (Argc=6, Argv=0x7fffffffd548) at main.cpp:50

If function verification (func.cpp:436) is called with llvm::PrintMessageAction, it reports the following:
Cannot allocate unsized type
%t = alloca %v8_varying_Test

Which makes perfect sense, as "Test" is not fully defined type. I.e. to make it work, you need to have in ispc file:
extern "C" struct Test {
int b;
};

This would be good to catch during LLVM IR generation and issue a nice error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants