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

Incorrect type of a function returning a reference to an array #74

Closed
languagelawyer opened this issue Sep 13, 2018 · 5 comments
Closed
Labels
bug Something isn't working

Comments

@languagelawyer
Copy link

For the following code

int arr[5][3];

decltype(auto) f(int i)
{
    return arr[i];
}

Insight produces (array declaration is skipped)

int (&)[3] f(int i)
{
  return arr[i];
}

whilst it shall be

int (&f(int i))[3]
{
  return arr[i];
}
@andreasfertig
Copy link
Owner

Hello languagelawyer,

thanks for reporting that. I'll have a look into it for how to fix it.

@languagelawyer
Copy link
Author

Prolly the easiest way to fix this is to use trailing return type.

@andreasfertig andreasfertig added the bug Something isn't working label Sep 16, 2018
andreasfertig added a commit that referenced this issue Sep 16, 2018
Fixed #74: Support array reference as return type.
@andreasfertig
Copy link
Owner

I just pushed a fix. Let me know what you think. It is without trailing return type and it passed all my existing tests.

@languagelawyer
Copy link
Author

languagelawyer commented Sep 16, 2018

I've already tested it at the cppinsights.io
I was thinking there is no easy way to put the function name into the correct place in such a function type with libclang, that is why I've proposed the use of trailing return type.
But I see that actually it is not difficult, so there is no need in trailing return type.

@andreasfertig
Copy link
Owner

Yeah the way is ugly. I insert it in the string. But I used this system already.
At some point I think I will implement my own AST to type version. But so far I can life with libclang.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants