-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Open
Labels
accepts-invalidclang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"
Description
This code compiles, unless we instantiate and call f()
. This doesn’t seem right to me because, irrespective of what the type of e.g. this
ends up being, it’s a prvalue, and we can’t increment that.
template <typename T>
struct S : T {
auto t() -> S*;
void f() {
++reinterpret_cast<S*>(4);
++this;
++t();
}
};
Imo we should diagnose this earlier if that is feasible. GCC also suffers from the same problem, which caused ++this
as a typo for ++*this
to go unnoticed in a libstdc++ header because the template containing it was never instantiated by libstdc++. MSVC also accepts this code. Is this a bug or a standards defect? Because I don’t see a situation where ++this
would be semantically valid.
Metadata
Metadata
Assignees
Labels
accepts-invalidclang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"