microsoft / microsoft/vscode-cpptools

VS Code showing error lines for parameter forward declaration syntax

Open
#10,681 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature Request Language Service parser Visual Studio
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Environment
  • OS and version: Ubuntu 22.10
  • VS Code: 1.76.1
  • C/C++ extension: v1.14.4
  • OS and version of remote machine (if applicable):
  • GDB / LLDB version:
Bug Summary and Steps to Reproduce

Bug Summary:

Parameter forward declaration is not supported in C99, but it is supported in modern C. Compiler is not throwing any error, but VS Code shows me error squiggles.

https://stackoverflow.com/questions/17771484/what-is-a-parameter-forward-declaration/17771494#17771494

Steps to reproduce:

  1. In Ubuntu 22.10, VS Code 1.76.1, with C/C++ extension v1.14.4

image

  1. write this code


#include <stdio.h>

void display(int l; int arr[l], int l) {

    printf("[ ");

    for (int i = 0; i < l; i++) {
        printf("%d  ", arr[i]);
    }
    printf(" ]\n");
}

void insertionSort(int l; int arr[l], int l) {
    for (int i = 1; i < l; i++) {
        int curr = arr[i];
        int j = i - 1;
        while (j >= 0 && arr[j] > curr) {
            arr[j + 1] = arr[j];
            j--;
        }
        arr[j + 1] = curr;
    }
}

int main() {
    int arr[10] = {2, 5, 1, 4, 9, 8, 3, 10, 11, 7};
    display(arr, 10);
    insertionSort(arr, 10);
    display(arr, 10);
}

  1. See error red lines shown by vs code
    image

But compiling with gcc -Wall program.c shows no error, and program works as expected.

Debugger Configurations
I am not using debugger
Debugger Logs
debugger not used
Other Extensions

No response

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the diagnostics in VS Code 1.76.1 with C/C++ extension v1.14.4 using the example in program.c, then compare the result with gcc -Wall. Done means valid parameter forward declaration syntax no longer receives erroneous red squiggles while genuine errors remain reported.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, vscode
Domain
compilers, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.