Skip to content

[clang-tidy] False positive misc-const-correctness with double pointers #131599

Open
@carlosgalvezp

Description

@carlosgalvezp

Consider this code frequently found when interacting with C API:

void foo(void**);

void bar()
{
    void* ptr{};
    foo(&ptr);
}

Here, clang-tidy wants ptr to be void const* ptr , i.e. pointing to const void. This change makes the program no longer compile.

https://godbolt.org/z/GrPYf7Gao

The warning goes away if I remove the braces initializing ptr. But as a user I should be able to do that anyway (some other guidelines require this).

Activity

llvmbot

llvmbot commented on Mar 17, 2025

@llvmbot
Member

@llvm/issue-subscribers-clang-tidy

Author: Carlos Galvez (carlosgalvezp)

Consider this code frequently found when interacting with C API:
void foo(void**);

void bar()
{
    void* ptr{};
    foo(&ptr);
}

Here, clang-tidy wants ptr to be void const* ptr , i.e. pointing to const void. This change makes the program no longer compile.

https://godbolt.org/z/GrPYf7Gao

The warning goes away if I remove the braces initializing ptr. But as a user I should be able to do that anyway (some other guidelines require this).

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

        Participants

        @carlosgalvezp@llvmbot

        Issue actions

          [clang-tidy] False positive misc-const-correctness with double pointers · Issue #131599 · llvm/llvm-project