[llvm-bugs] [Bug 45162] New: [concepts] requires expression wrongly evaluates to true within a class template
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Mar 9 22:40:33 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=45162
Bug ID: 45162
Summary: [concepts] requires expression wrongly evaluates to
true within a class template
Product: clang
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: C++2a
Assignee: unassignedclangbugs at nondot.org
Reporter: heavenandhell171 at gmail.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk,
saar at raz.email
$ clang++.exe --version
clang version 11.0.0 (https://github.com/llvm/llvm-project.git
fc3c80c38643aff6c4744433ab485c7550ee77b9)
$ cat test.cpp
#ifdef BUG
template <typename T>
#endif
struct test_t {
template <typename U>
int exec(U) {
if constexpr (requires { this->is_memmovable<U>(); })
return 1;
else
return 0;
}
template <typename>
requires false
auto is_memmovable() -> void;
};
int test() {
#ifdef BUG
using test_type = test_t<int>;
#else
using test_type = test_t;
#endif
return test_type{}.exec(0);
}
$ clang++.exe -std=c++2a -O3 -c -S -o - test.cpp -DBUG
"?test@@YAHXZ": # @"?test@@YAHXZ"
# %bb.0:
movl $1, %eax
retl
$ clang++.exe -std=c++2a -O3 -c -S -o - test.cpp
"?test@@YAHXZ": # @"?test@@YAHXZ"
# %bb.0:
xorl %eax, %eax
retl
The requires expression only gives the wrong result if test_t is a template.
Otherwise it correctly evaluates to false.
--
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/20200310/d445b6de/attachment.html>
More information about the llvm-bugs
mailing list