Open
Description
I have, for years, had longstanding red code in a project that compiles and runs fine. I eventually isolated an example, and found that even trivial use of std::tuple would cause red code.
For example, in code such as this:
#include <tuple>
int x;
std::tuple<int> tup(x);
'tup' would show as red, when it shouldn't.
Digging further into the header files I was using in Eclipse (those from Cygwin x86-64, for gcc 11), and simplifying header file contents, I simplified the problem to the following:
// Stripped down version of std::true_type
struct True { static constexpr bool value = true; }
// Stripped down version of std::__and_
template<typename B> struct Truthy;
template<typename B> struct Truthy<B> { static constexpr bool value = true;};
// Stripped down version of std::enable_if
template<bool> struct MaybeBool {};
template<> struct MaybeBool<true> { using type = bool; };
// Stripped down version of std::tuple
struct Broken
{
// Eclipse doesn't seem to be able to figure out that
// Truthy<int>::value is true, and that therefore
// MaybeBool<Truthy<int>::value> should expand to 'bool',
// and that therefore the template becomes "template<bool = true>"
// which is valid according to SFINAE, and that therefore the
// constructor should not be removed due to specification failure.
template<typename MaybeBool< Truthy<int>::value >::type = true>
Broken(const int& elems) noexcept {}
// Note that uncommenting the following lines will cause the
// red below to go away.
// template<typename MaybeBool< True::value >::type = true>
// Broken(const int& elems) noexcept {}
// Note that uncommenting the following lines will cause the
// red below to go away.
// template<typename MaybeBool< true >::type = true>
// Broken(const int& elems) noexcept {}
};
int keyCompData = 5;
Broken blarg1(keyCompData); // blarg1 is red.
Broken blarg2{ keyCompData }; // blarg2 is underlined red.