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
member function void foo() __restrict__;
incorrectly applies restrict to type, not pointer
#18121
Comments
*** Bug llvm/llvm-bugzilla-archive#17793 has been marked as a duplicate of this bug. *** |
I ran into this again while working on debug info, and wrote up a long bug report to discover that it was a duplicate. See also #11039 . |
I also ran into this bug, and also wrote up a long bug report to discover that it was a duplicate. So, I'll try to add a bit more information. This bug is almost 7 years old now! So first, this still occurs in Clang trunk 12.0.0 (but way earlier also; I checked as far back as 3.0.0). I can't give a cleaner example than the OP, but I will comment that Clang's error message is, specifically:
It is also worth noting the GCC, MSVC, ICC, and possibly others all do not suffer from this problem. As has been mentioned, the bug is that Clang appears to think that the type of
Note: while Note: a C-style cast works around this problem, but obviously this is not a solution. |
mentioned in issue llvm/llvm-bugzilla-archive#17793 |
…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.
@llvm/issue-subscribers-clang-frontend Author: Sean Silva (silvasean)
| | |
| --- | --- |
| Bugzilla Link | [17747](https://llvm.org/bz17747) |
| Version | trunk |
| OS | Linux |
| CC | @majnemer,@DougGregor,@imallett,@rnk |
Extended Descriptionstruct Foo { Clang gives the diagnostic: test.cpp:3:23: error: cannot initialize a variable of type 'Foo *restrict' with Clang seems to think that The GCC extension says: <http://gcc.gnu.org/onlinedocs/gcc/Restricted-Pointers.html#Restricted-Pointers> "Within the body of T::fn, this has the effective definition T *restrict const this." |
Extended Description
Clang gives the diagnostic:
Clang seems to think that
this
has typerestrict Foo *
(restrict onFoo
, rather than the pointer)The GCC extension says:
http://gcc.gnu.org/onlinedocs/gcc/Restricted-Pointers.html#Restricted-Pointers
"Within the body of T::fn, this has the effective definition T *restrict const this."
The text was updated successfully, but these errors were encountered: