Skip to content

misc-const-correctness.WarnPointersAsValues not detected with non-const member call #64955

@firewave

Description

@firewave
class T
{
public:
    void f(); // make function const for warning to appear
};

void f()
{
    T* /*const*/ t = new T();
    t->f();
}

https://godbolt.org/z/TW3r5Y1d8

The pointer can be const. As this is just about the variable and not the type it should not matter what kind of member is called on it.
The warning does trigger if you access a non-function member.

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