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

Returning reference from cometa::function results in compile error on Windows/Clang/LLVM. #1

Closed
degski opened this Issue Aug 31, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@degski
Copy link

degski commented Aug 31, 2016

When returning a reference type from cometa::function<something & (some parameters...)> on Windows VC14/Update3 with Clang/LLVM (http://llvm.org/builds/) a compiler error is raised. Returning a pointer cometa::function<something * (some parameters...)> works fine, and is obviously a work-around, but it would be nice to have a reference returned.

edited: clarify what I intended to say.

dlevin256 added a commit that referenced this issue Sep 1, 2016

Fix returning reference (#1) and add corresponding test
Behavior changed.
segfault (Access violation) will be raised at runtime if an empty
function is called.
@dlevin256

This comment has been minimized.

Copy link
Member

dlevin256 commented Sep 1, 2016

Fixed in 84b4972.
The previous implementation returned default-constructed value of the Return type if an empty function was being called.
But because the reference types haven't empty value, now segfault (Access violation) will be raised at runtime if an empty function is called. Enclose the call in an if-statement to prevent segfault.
Thanks.

@dlevin256 dlevin256 closed this Sep 1, 2016

@dlevin256 dlevin256 reopened this Sep 1, 2016

@dlevin256 dlevin256 closed this in 6b8b9b7 Sep 1, 2016

@degski

This comment has been minimized.

Copy link

degski commented Sep 1, 2016

Fixed indeed, thanks...

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