Skip to content

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

@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).

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