[Bug c++/86191] Partial ordering with an expression involving non-type template parameters
jason at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Jun 18 19:37:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86191
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |SUSPENDED
Summary|[6/7/8/9 Regression] A |Partial ordering with an
|missing error message? |expression involving
| |non-type template
| |parameters
--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to zhonghao from comment #0)
> The code is as follow:
>
> template<int i> struct g {};
>
> template<int i, int j> void f(g<i/j>) { }
> template<int i, int j> void f(g<j>) { }
>
> int main()
> {
> f<4,2>(g<4/2>());
> }
>
> When clang++ compiles the code, it produces the following messages:
> 1gcc01.cpp:8:3: error: call to 'f' is ambiguous
> 1gcc01.cpp:3:29: note: candidate function [with i = 4, j = 2]
> 1gcc01.cpp:4:29: note: candidate function [with i = 4, j = 2]
> template<int i, int j> void f(g<j>) { }
>
> However, when g++ compiles the code, it does not produce any error messages.
> Is the code legal or not? For me, it seems that the messages of clang++ are
> reasonable.
In partial ordering, it seems that we can deduce j#2 to i#1/j#1, but we can't
do any deduction in the other direction, so f#1 is more specialized. We don't
need to deduce a value for i#2 because it's not used in the function
parameters. I don't see why this would be ambiguous.
More information about the Gcc-bugs
mailing list