-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
[Clang] Accepts invalid constructor declaration with an asterisk #121706
Comments
Just FYI, GCC has a similar bug and was filed as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118306 (there was also a recent regression with an ICE when defaulting the constructor which the reporter here reported to GCC as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118304 ). |
@llvm/issue-subscribers-clang-frontend Author: None (MagentaTreehouse)
```c++
struct A {
*A();
};
```
See Compiler Explorer: https://compiler-explorer.com/z/ccf6rqenE
|
Fun to note it accepts any number of asterisks: https://compiler-explorer.com/z/naaP75err struct A {
******************A();
}; we can bring the whole gang along: https://compiler-explorer.com/z/TY8aq8G9W struct A {
****A();
***~A();
**A(const A&);
*A(A&&);
}; goes back to clang-2.6: https://compiler-explorer.com/z/zWv4b45s7 |
To generalize further, Clang seems to allow any of the ptr-operators in the ptr-declarator for constructors and destructors. Consider also these accepts-invalid cases: https://compiler-explorer.com/z/qdbdsjbWh struct A {
*&A();
};
struct B {
*&&B();
};
struct C {
*const C();
};
struct D {
*const *D();
};
struct E {
*E::*E();
};
struct F {
*F::*const F();
}; Only to fail when there is a struct G {
&G();
}; Output: <source>:2:5: error: cannot form a reference to 'void'
2 | &G();
| ^ |
See Compiler Explorer: https://compiler-explorer.com/z/ccf6rqenE
The text was updated successfully, but these errors were encountered: