Skip to content

False positive with unnamed function parameter #131

Open

Description

@WasabiFan

With the following example file:

void foo(int)
{
    return;
}

I get:

# cpplint test.cpp 
...
test.cpp:1:  Using C-style cast.  Use static_cast<int>(...) instead  [readability/casting] [4]
...
# cpplint --version
Cpplint fork (https://github.com/cpplint/cpplint)
cpplint 1.4.5
Python 3.8.0 (default, Nov 23 2019, 05:49:00) 
[GCC 8.3.0]

There isn't a cast in this file; it's picking up the parameter type in the function definition.

I removed the parameter name to avoid "unused variable" warnings (https://stackoverflow.com/a/15763959/2422874).

Activity

  1. tkruse commented on Jun 2, 2020

    @tkruse
    Contributor

    It seems that this is avoided when the curly braces are at the end of the line.
    cpplint.py already tries to avoid this false positive, but the code to do so in CheckCasts( is very contrived, and I am not brave enough to try to fix this.

  2. added a commit that references this issue on Aug 24, 2021
  3. added a commit that references this issue on Aug 29, 2021
  4. added a commit that references this issue on Sep 29, 2021
  5. added a commit that references this issue on Jan 13, 2022
  6. vkucera commented on Jul 8, 2024

    @vkucera

    Any prospects on fixing this bug?

  7. added a commit that references this issue on Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions