Skip to content

false positive for clang-tidy rule 'misc-const-correctness' #66204

@a3emdot

Description

@a3emdot

I use clang-tidy 15.0.7 from Fedora 37

consider the following reproducer

#include <iostream>

class X {
public:
	int a;
	int b;
};

void func( X& x, int X::* m )
{
	/*const*/ X& tmp = x;

	tmp.*m = 77;
}

int main()
{
	X x;
	x.a = 0;
	x.b = 0;

	std::cout << x.a << " " << x.b << std::endl;

	func(x, &X::a);

	std::cout << x.a << " " << x.b << std::endl;

	return 0;
}

The /* const */ marked line gets tagged with 'misc-const-correctness'.
Though adding that 'const' clearly results in a compilation error with g++ (12.3.1) or clang++ (15.0.7)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions