[llvm-bugs] [Bug 51934] New: class definition not allowed to change meaning of previously used name
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Sep 22 01:25:52 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=51934
Bug ID: 51934
Summary: class definition not allowed to change meaning of
previously used name
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: gonzalo.gadeschi at gmail.com
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
See http://eel.is/c++draft/class.member.lookup#6
[class.member.lookup]/p6: "If it [the result of the search] differs from the
result of a search in T for N from immediately after the class-specifier of T,
the program is ill-formed, no diagnostic required." A class definition is not
allowed to change the meaning of a name that was already used earlier in the
class definition.
While no diagnostic is required, I think a quality implementation like clang
should produce a diagnostic here and reject this program since it is
ill-formed.
Example: https://gcc.godbolt.org/z/zG7Mn1Ebx
struct plus {
template<typename... Args>
using invoke = void;
};
template <typename Fn, typename... Args>
using invoke = typename Fn::template invoke<Args...>;
template <typename Fn>
struct compose
{
template <typename X, typename Y>
using F = invoke<Fn, X, Y>;
template <typename X>
using invoke = invoke<Fn, X, X>;
};
using Q = compose<plus>::F<int, int>;
Is accepted by clang.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210922/7e72ca9c/attachment.html>
More information about the llvm-bugs
mailing list