-
Notifications
You must be signed in to change notification settings - Fork 13.6k
clang fails to consider the most specialized template definition when it's partialy specialized with multiple template template parameters #37392
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
Comments
Well, it's legal, but it's relying on a language change from the C++17 timeframe. See http://clang.llvm.org/cxx_status.html#p0522 and wg21.link/p0522. Prior to that language change, type_list is not a valid template template argument for the List template template parameter of the front partial specialization, because the argument's template parameters don't match those of the parameter. However, P0522 has a hole in it that causes it to reject significant amounts of existing code and sadly has still not been fixed (nor has a fix even been agreed by the C++ core working group), so we don't enable it by default. (GCC has implemented what they think the fix will be; I'm not sure what MSVC has done.) You can use -frelaxed-template-template-args to enable support for P0522. |
Thank you for your quick reply and explanation. Now that I know where the problem is, I can make code fix so that I have matching template template parameter in case the option break too much of my existing code. |
@zygoloid @hubert-reinterpretcast Is there a DR tracking this hole in |
@zygoloid I ran into that again today, do you know if a fix is being pursued by anyone? Should clang adopt gcc's behavior? |
@cor3ntin I don't know if anyone is working on this. I recall that we were going to try enabling |
@erichkeane @AaronBallman maybe worth bringing this up in the next Clang Language Working Group meeting |
There WAS an effort to turn that on not long ago... was it @ChuanqiXu9 ? I don't remember what is holding it up. |
I don't remember I have looked into such issues. |
It was https://reviews.llvm.org/D109496 |
I thought we had one more recently than that as well? But I don't recall who was doing it. |
@llvm/issue-subscribers-clang-frontend |
Uh oh!
There was an error while loading. Please reload this page.
Extended Description
I was doing simple metaprogramming recently and wanted to code the "front" helper: get the first type of a type list.
So I experimented on wandbox this code :
There's nothing fancy (Please let me know if the code above is not legal C++). Usage is :
The problem is when I'm specializing with a template template like this :
Then clang throws it away and doesn't find anything.
However, if I specialize only with :
Then it's fine and clang doesn't throw it away (but it's not ok because I can't do what I want to do this way).
I think clang is wrong here and should consider this specialization.
It consistently fails since clang 4.0 haven't tested the version before) up until trunk.
FWIW, both gcc and msvc compile it just fine.
Here's a godbolt repro : https://godbolt.org/g/M5fgbj
Please let me know if what I'm writing is not legal C++.
The text was updated successfully, but these errors were encountered: