Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

GNU extension: Support forward declaring function parameters #47617

Copy link
Copy link
@josephcsible

Description

@josephcsible
Issue body actions
Bugzilla Link 48273
Version 11.0
OS Linux
CC @zygoloid

Extended Description

Consider this C function:

void transpose(double (*)[*], int);
void transpose(array, size)
  int size;
  double (*array)[size];
{
  for (int i=1; i<size; i++)
  {
    for (int j=0; j<i; j++)
    {
      double t = array[i][j];
      array[i][j] = array[j][i];
      array[j][i] = t;
    }
  }
}

It uses a K&R function definition, which is deprecated and will probably be removed in C2x. To my knowledge, there's no standard replacement for that since the VLA comes before its size, but a GNU extension allows forward declaring parameters, like this:

void transpose(double (*)[*], int);
void transpose(int size; double (*array)[size], int size)
{
  for (int i=1; i<size; i++)
  {
    for (int j=0; j<i; j++)
    {
      double t = array[i][j];
      array[i][j] = array[j][i];
      array[j][i] = t;
    }
  }
}

Today, GCC will accept that code, but Clang will not. Can support for that GNU extension be added to Clang as well?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaIssues migrated from bugzillaclang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"enhancementImproving things as opposed to bug fixing, e.g. new or missing featureImproving things as opposed to bug fixing, e.g. new or missing featureextension:gnu

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.