Skip to content

Incorrect return type of a function returning a pointer to an array #81

@rayhamel

Description

@rayhamel

See #74.

For this snippet

auto f(int i)
{ // also `decltype(auto) f(int i)`, `int(*f(int i))[3]` and `auto f(int i) -> int(*)[3]`
  static int arr[5][3];
  return &arr[i];
}

Insights incorrectly outputs

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

and for this snippet

auto *f(int i)
{
  static int arr[5][3];
  return &arr[i];
}

Insights incorrectly outputs

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

instead of the correct output for both snippets.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions