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
"1st argument ('__restrict int') would lose restrict qualifier" when passing (this restrict *)->int to int& argument #82941
Comments
The following example confirms this: class C
{
void g() __restrict;
};
void C::g() __restrict
{
double x = this;
} fails with:
note that the diagnostic says
|
This does not compile correctly when using Clang [1]. [1]: llvm/llvm-project#82941
This does not compile correctly when using Clang [1]. [1]: llvm/llvm-project#82941
@llvm/issue-subscribers-clang-frontend Author: наб (nabijaczleweli)
```cpp
void f(int& x) {
(void)x;
}
class C { void C::g() __restrict {
a.cpp:11:5: error: no matching function for call to 'f'
|
Based on gcc documentation: https://gcc.gnu.org/onlinedocs/gcc/Restricted-Pointers.html it does not look like we are doing the right thing here but not sure. |
Yeah, this AST looks wrong to me: https://godbolt.org/z/4P7a45dP1 specifically:
That should be a restricted pointer, not a restricted pointee. |
I think the issue seems to be that we treat |
…ns properly (#83187) When resolving the type of `this` inside a member function, we were attaching all qualifiers present on the member function to the class type and then making it a pointer; however, `__restrict`, unlike `const` and `volatile`, needs to be attached to the pointer type rather than the pointee type. This fixes #82941, #42411, and #18121.
(same for
void f(int const& x)
) compiles fine on GCC, but Clang 17 and 19.0.0 (++20240212105217+93cdd1b5cfa3-1~exp1~20240212225341.524) rejects it withI don't think this is valid – this looks like
this
is of typeC restrict *
, and thusx
is compatible withint restrict &
, and it's treating restrict like a cv-qualifier, which I don't think it is (and isn't for pointers), and even if it were I haven't found a position where you could make f take anint restrict &
.The text was updated successfully, but these errors were encountered: