-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[Clang][Sema] Disable checking invalid template id in initializer of primary variable template std::format_kind with libstdc++
#139560
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
Conversation
…le template `std::format_kind` with libstdc++
|
@llvm/pr-subscribers-clang Author: Yanzuo Liu (zwuis) ChangesFixes #139067 Full diff: https://github.com/llvm/llvm-project/pull/139560.diff 1 Files Affected:
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 7940340064eda..19142d7c16abb 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -4383,6 +4383,11 @@ Sema::CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc,
};
if (VarDecl *Var = Template->getTemplatedDecl();
+ // Skipping std::format_kind in libstdc++ is a hack for
+ // GH139067 / https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120190
+ !(Var->getName() == "format_kind" &&
+ Var->getDeclContext()->isStdNamespace() &&
+ PP.isMacroDefined("__GLIBCXX__")) &&
ParsingInitForAutoVars.count(Var) &&
llvm::equal(
CTAI.CanonicalConverted,
|
erichkeane
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test for this too?
clang/lib/Sema/SemaTemplate.cpp
Outdated
| // GH139067 / https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120190 | ||
| !(Var->getName() == "format_kind" && | ||
| Var->getDeclContext()->isStdNamespace() && | ||
| PP.isMacroDefined("__GLIBCXX__")) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great if we could find some sort of way to check the actual VERSION of the hack once they fix this, but it doesn't look like they have a fix in flight.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clang you add something like // HACK workaround libstdc++ 14.x (2025-02) so it's easier to find?
shafik
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please describe the issue in the summary instead of just saying it fixes .... Also add details such as this is fixing an issue introduced by ...
Also please as Erich asked, add a test too
|
@cor3ntin @erichkeane I question if a hack is really necessary here. We had run into a similar situation when we broke libstdc++ 14.1 (#92439), and the consensus then was to wait for the next dot release. I'd expect they'll fix this issue in the next dot release too? @jwakely Will the next GCC release come before Clang 21, i.e. before September? |
|
@zyn0217 At the very minimum, it breaks compiler explorer and anyone who uses trunk; it is disruptive |
|
I think we should
I don't have time at the moment but it would be a useful improvement :) |
*4/ Do an audit of all our libcxx hackery in place right now, and apply the new function to it :D And perhaps instead of |
|
@zwuis Can you land that? Thanks! |
|
@cor3ntin I don't have commit access. Please help me land this. By the way, should I request commit access? |
It might be a good idea ! https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access |
…d` (#140831) We can use 20250520 as the final date, see the following commits. - GCC releases/gcc-15 branch: - https://gcc.gnu.org/g:fedf81ef7b98e5c9ac899b8641bb670746c51205 - https://gcc.gnu.org/g:53680c1aa92d9f78e8255fbf696c0ed36f160650 - GCC master branch: - https://gcc.gnu.org/g:9361966d80f625c5accc25cbb439f0278dd8b278 - https://gcc.gnu.org/g:c65725eccbabf3b9b5965f27fff2d3b9f6c75930 Follows-up #139560.
#134522 triggers compilation error with libstdc++, in which primary variable template
std::format_kindis defined likeSee #139067 or https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120190.
This PR disables checking template id in initializer of primary variable template
std::format_kindin libstdc++ (by checking__GLIBCXX__).Fixes #139067