Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[concepts] requires expression wrongly evaluates to true within a class template #44507

Closed
Ivan171 opened this issue Mar 10, 2020 · 5 comments
Closed
Labels
bugzilla Issues migrated from bugzilla c++20

Comments

@Ivan171
Copy link

Ivan171 commented Mar 10, 2020

Bugzilla Link 45162
Resolution FIXED
Resolved on Mar 19, 2020 02:30
Version trunk
OS Windows NT
CC @zmodem,@zygoloid,@saarraz
Fixed by commit(s) 9769e1e

Extended Description

$ clang++.exe --version
clang version 11.0.0 (https://github.com/llvm/llvm-project.git fc3c80c)

$ cat test.cpp
#ifdef BUG
template
#endif
struct test_t {
template
int exec(U) {
if constexpr (requires { this->is_memmovable(); })
return 1;
else
return 0;
}

template
requires false
auto is_memmovable() -> void;
};

int test() {
#ifdef BUG
using test_type = test_t;
#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.

@saarraz
Copy link
Contributor

saarraz commented Mar 10, 2020

Fixed, thanks for reporting :)

@Ivan171
Copy link
Author

Ivan171 commented Mar 14, 2020

Oh that was quick, thanks Saar.

I think it fixed another problem i was having. I've tried to create a minimal repro yesterday, but Clang didn't crash.

I was wondering, is it possible to backport the fix to the release/10.x branch?

@saarraz
Copy link
Contributor

saarraz commented Mar 14, 2020

I believe it was back ported, check the rc4 build

@Ivan171
Copy link
Author

Ivan171 commented Mar 15, 2020

It`s not working with rc4.

I`ve checked the commits at https://github.com/llvm/llvm-project/commits/release/10.x, and the commit that fixed the issue is not listed there.

@zmodem
Copy link
Collaborator

zmodem commented Mar 19, 2020

Saar's fix will in rc5.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++20
Projects
None yet
Development

No branches or pull requests

3 participants