[Bug c++/92918] New: Does not do name lookup when using from base class
CoachHagins at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Dec 12 02:31:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92918
Bug ID: 92918
Summary: Does not do name lookup when using from base class
Product: gcc
Version: 9.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: CoachHagins at gmail dot com
Target Milestone: ---
This bug exists on all versions of the compiler I tried, including the current
branch.
Here is a link to compiler explorer with the code example:
https://godbolt.org/z/wYo-4n
And here is a copy/paste of the code. Compile with "-std=c++17 -DSHOW_BUG"
It shows several similar cases where the code compiles, followed by the case
which does not compile.
-----
#include <cstddef>
class ThisCompilesOnGCC {
static void impl(char const *);
public:
template <typename T>
[[nodiscard]] constexpr auto operator()(const T &t) const noexcept
-> decltype(impl(t))
{
return impl(t);
}
};
void thisCompilesOnGCC() {
ThisCompilesOnGCC{}("42");
}
class Base01 {
protected:
static void impl(char const *);
};
class ThisAlsoCompilesOnGCC : private Base01 {
using Base01::impl;
public:
template <typename T>
[[nodiscard]] constexpr auto operator()(const T &t) const noexcept
-> decltype(impl(t))
{
return impl(t);
}
};
void thisAlsoCompilesOnGCC() {
ThisAlsoCompilesOnGCC{}("42");
}
class Base02 {
protected:
static void impl(char const *);
};
class ThisCompilesOnGCCToo : private Base02 {
using Base02::impl;
static void impl(int);
public:
template <typename T>
[[nodiscard]] constexpr auto operator()(const T &t) const noexcept
-> decltype(impl(t))
{
return impl(t);
}
};
void thisCompilesOnGCCToo() {
ThisCompilesOnGCCToo{}("42");
}
#if defined (__clang__) || defined(SHOW_BUG)
// This compiles with clang - but not with gcc
class Base03 {
protected:
static void impl(int);
};
class ThisDoesNotCompileOnGCC : private Base03 {
using Base03::impl;
static void impl(char const *);
public:
template <typename T>
[[nodiscard]] constexpr auto operator()(const T &t) const noexcept
-> decltype(impl(t))
{
return impl(t);
}
};
void thisDoesNotCompileOnGCC() {
ThisDoesNotCompileOnGCC{}("42");
}
#endif
More information about the Gcc-bugs
mailing list