Skip to content

[clang-tidy][false-positive] misc-const-correctness warns non-const pointer parameter despite passing function into function pointer #236012

Description

@tearfur

https://godbolt.org/z/fG16E4Pev

misc-const-correctness warns that pointee of a pointer parameter from a function should be const, yet the very same function is passed into a function pointer that has a non-const pointer parameter.

We don't always control the function pointer signature. And in cases we don't control the signature, following the suggestion will cause the code to FTBFS.

<source>:4:14: warning: pointee of variable 'p' of type 'T *const' can be declared 'const' [misc-const-correctness]
    4 | void destroy(T* const p) { delete p; }
      |              ^
      |                const
1 warning generated.

Current trunk: 21a3030

Activity

  1. llvmorg-github-actions commented on Oct 27, 2026

    @llvmorg-github-actions

    @llvm/issue-subscribers-clang-tidy

    Author: Yat Ho (tearfur)

    Details https://godbolt.org/z/fG16E4Pev

    misc-const-correctness warns that pointee of a pointer parameter from a function should be const, yet the very same function is passed into a function pointer that has a non-const pointer parameter.

    We don't always control the function pointer signature. And in cases we don't control the signature, following the suggestion will cause the code to FTBFS.

    &lt;source&gt;:4:14: warning: pointee of variable 'p' of type 'T *const' can be declared 'const' [misc-const-correctness]
        4 | void destroy(T* const p) { delete p; }
          |              ^
          |                const
    1 warning generated.
    

    Current trunk: 21a3030

  2. yashaggarwal85d commented on Oct 27, 2026

    @yashaggarwal85d
    Contributor

    Hi! I have raised a pull request for this issue, lemme know if any change is needed. Thanks!

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions