[Bug c++/56506] variadic class template specialization not selected as best match

2024-04-04 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56506

--- Comment #7 from Andrew Pinski  ---
(In reply to Andrew Pinski from comment #6)
> I should note clang accepts the code.

But EDG does not.
While MSVC accepts it.

[Bug c++/56506] variadic class template specialization not selected as best match

2024-04-04 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56506

--- Comment #6 from Andrew Pinski  ---
(In reply to Andrew Pinski from comment #5)
> Confirmed. This ICEs on the trunk (but I don't think it is a regression as
> the assert is a gcc_checking_assert).
> 
> The ICE:
> 
> :12:28: internal compiler error: in comptypes, at cp/typeck.cc:1684
>12 |   Y,char>>::type x;
>   |^~

I should note clang accepts the code.

[Bug c++/56506] variadic class template specialization not selected as best match

2024-04-04 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56506

Andrew Pinski  changed:

   What|Removed |Added

   Last reconfirmed||2024-04-04
 Ever confirmed|0   |1
 Status|UNCONFIRMED |NEW
   Keywords||ice-checking,
   ||ice-on-valid-code

--- Comment #5 from Andrew Pinski  ---
Confirmed. This ICEs on the trunk (but I don't think it is a regression as the
assert is a gcc_checking_assert).

The ICE:

:12:28: internal compiler error: in comptypes, at cp/typeck.cc:1684
   12 |   Y,char>>::type x;
  |^~

[Bug c++/56506] variadic class template specialization not selected as best match

2013-03-05 Thread daniel.kruegler at googlemail dot com

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56506

--- Comment #4 from Daniel Krügler daniel.kruegler at googlemail dot com 
2013-03-05 20:18:00 UTC ---
(In reply to comment #3)
Presumably my judgment was a bit premature and I think there is a logical flaw
in my original argumentation: I think I misinterpreted 14.5.3 p5. I'm switching
to observer-mode, but your examples are quite interesting because every
compiler with variadic template support that I have access to rejects them.
This seems to indicate some possible unforeseen case in existing models. I have
forwarded this to the core language group.


[Bug c++/56506] variadic class template specialization not selected as best match

2013-03-04 Thread mmehlich at semanticdesigns dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56506



--- Comment #3 from Michael Mehlich mmehlich at semanticdesigns dot com 
2013-03-04 16:58:45 UTC ---

Considering that based on 14.5.3(5) a template member declaration

  XYZT...,T...::type x;

with T bound to int,bool,char must expand to

  XYZint,bool,char,int, 

  YZint,bool,char,bool, 

  YZint,bool,char,char::type x;

I'd consider it rather counter-intuitive if I cannot get a match as described

in my original message.



Does the standard actually specify how the matching process works in detail

in the presence of variadic templates?  Going through the template section,

I haven't found anything definite that would put light onto this issue

(though I might have missed it).



I can't really understand your because it is not followed by ...;

after all, in XYZT..., U... the parameter pack U is also not immediately

followed by a ..., so why is that case ok but my original one isn't?



It is pretty easy to implement a matcher that successfully matches the case

in the original message, so I don't think the standard has any excuse not to

consider this a successful match, either.  

Notwithstanding that, the standards committee might have decided otherwise.

If so, where does it say so in the standard, resp. how can I conclude this

from what I can find in there?



--

  Michael


[Bug c++/56506] variadic class template specialization not selected as best match

2013-03-03 Thread daniel.kruegler at googlemail dot com

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56506

Daniel Krügler daniel.kruegler at googlemail dot com changed:

   What|Removed |Added

 CC||daniel.kruegler at
   ||googlemail dot com

--- Comment #2 from Daniel Krügler daniel.kruegler at googlemail dot com 
2013-03-03 19:46:42 UTC ---
I don't think that either example should be accepted. My understanding is, that
the second T is still considered as a parameter pack but not as an expansion
(because it is not followed by ...) at the time of pattern match checking,
therefore the compiler would try to match a sequence of expansions from the
first T... with a corresponding parameter pack. But this pack is always
considered as a different type, even if it would contain the same single type
(e.g. consider an argument type YZint, int where we would try to match
'int' with '[int]' where I use square brackets to denote the still existing
pack). So both cannot be the same type, and this specialization can never be
found. It would work, if you would declare the partial specialization as:

templatetypename... T, typename... U  
struct XYZT..., U... 
{
  typedef int type;
};

because now the compiler don't needs to cross-match corresponding T expansions
with the U pack.

I understand that this is a somewhat more generous specialization as you would
like to have, though.


[Bug c++/56506] variadic class template specialization not selected as best match

2013-03-02 Thread mmehlich at semanticdesigns dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56506



--- Comment #1 from Michael Mehlich mmehlich at semanticdesigns dot com 
2013-03-02 18:55:43 UTC ---

Some more information using a function template instead of a class template:



-- Additional code

templatetypename ... T void foo(YZT...,T...) {

}



int main() {

YZint,bool,char,int yi;

YZint,bool,char,bool yb;

YZint,bool,char,char yc;

foo(yi,yb,yc);

}



-- Error message from gcc 4.7.2:

test.cpp: In function 'int main()':

test.cpp:31:14: error: no matching function for call to 'foo(YZint, bool,

char, int, YZint, bool, char, bool, YZint, bool, char, char)'

test.cpp:31:14: note: candidate is:

test.cpp:15:31: note: templateclass ... T void foo(YZT ..., T...)

test.cpp:15:31: note:   template argument deduction/substitution failed:

test.cpp:31:14: note:   deduced conflicting types for parameter 'T' ('int,

bool, char' and 'int')

test.cpp:31:14: note:   'YZint, bool, char, int' is not derived from 'YZT

..., T'



It looks like the compiler decides to bind T to int when handling the

first argument instead of binding a prefix of T to int.