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

Wrong cast to non scalar type, and some other problems. #986

Open
cNoNim opened this issue Mar 27, 2016 · 3 comments
Open

Wrong cast to non scalar type, and some other problems. #986

cNoNim opened this issue Mar 27, 2016 · 3 comments

Comments

@cNoNim
Copy link

cNoNim commented Mar 27, 2016

I try build rock in Visual Studio 2015, but got several bugs which i don't understand.
I can fix that manually in C source, but I think it's wrong.

I tried minimize broken code, and:

Handler: interface {
    onHandle: func
}

DefaultHandler: class implements Handler {
    init: func
    onHandle: func
}

Foo : class {
    handler: Handler { get set }
    init: func {
        handler = DefaultHandler new()
    }
}

main: func {
    foo := Foo new()
    foo handler onHandle()
}

in C source I got... example:

Handler__reference test_temp__Foo___gethandler__(test_temp__Foo* this) {
    return (Handler__reference) ((test_temp__FooClass *)((lang_types__Object *)this)->class)->__gethandler__((test_temp__Foo*)this);
}

Handler_reference is struct, and I think such cast is GCC extension not allowed in C99, and in Visual C.

Next. In some places uses structs without member, is also GCC extension imho, and Visual C++ throw

error C2016: C requires that a struct or union has at least one member.

And finally. When I tried minimize broken code, I write:

Handler: interface {
    onHandle: func
}

DefaultHandler: class implements Handler {
    init: func
    onHandle: func
}

main: func {
    handler: Handler
    handler = DefaultHandler new()
    handler onHandle()
}

and got

lang_Numbers__Int main(lang_Numbers__Int __test_temp_argc1, lang_Character__CString* __test_temp_argv2) {
...
    Handler__reference handler = NULL; // 1
    handler = test_temp__DefaultHandler_new(); // 2
    test_temp__Handler_onHandle((Handler__reference) handler); // 3
    return 0;
}

in 1 place struct Handler__reference initialized like pointer
in 2 place DefaultHandler * assigned to struct Handler_reference
in 3 place we also have cast to non scalar type.

@alexnask
Copy link
Collaborator

Hi and thanks for the report.

Interfaces are a known buggy feature and MSVC compatibility has not been tested in a long time.
However, I will take a look into these tomorrow, especially the last issue you pointed out.

@cNoNim
Copy link
Author

cNoNim commented Mar 27, 2016

Hi and thanks for the respond

I can build and test rock on MSVC, and fix not cross-platform places, but first I think need fix GCC specific code.

To build rock on MSVC I change some places:

Then I use --driver=dummy or bootstrap C source and manually add files to MSVC project.

@horasal
Copy link
Contributor

horasal commented Mar 28, 2016

You can also use cmake driver to generate msvc project files.

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

No branches or pull requests

3 participants