It is an ODR-violation footgun when used in header files.

On 16 August 2022 12:53:00 BST, Frederick Virchanza Gotham via Std-Proposals <std-proposals@lists.isocpp.org> wrote:
Every C++ compiler suite I'm aware of supports the preprocessor macro
__COUNTER__.

So if I do the following:

#include <iostream>

auto main(void) -> int
{
std::cout << __COUNTER__ << std::endl;
std::cout << __COUNTER__ << std::endl;
std::cout << __COUNTER__ << std::endl;
std::cout << __COUNTER__ << std::endl;
}

Then it prints:
0
1
2
3

I see that in C++20 we have "std::source_location" which can probably
take the place of __FILE__, __LINE__, and maybe also __COUNTER__ in
some scenarios, but I still think __COUNTER__ should be standard C++.
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals