g++ and clang++ different behaviour deducing variadic template `auto` values

前端 未结 1 1845
梦如初夏
梦如初夏 2021-02-19 00:45

Another \"who\'s right between g++ and clang++?\"

This time I\'m convinced it\'s a g++ bug, but I ask for a confirm from standard gurus.

Given the following cod

1条回答
  •  执念已碎
    2021-02-19 01:39

    None of the three compilers is correct.

    From [temp.param]/17:

    If a template-parameter is a type-parameter with an ellipsis prior to its optional identifier or is a parameter-declaration that declares a pack ([dcl.fct]), then the template-parameter is a template parameter pack. A template parameter pack that is a parameter-declaration whose type contains one or more unexpanded packs is a pack expansion. ... A template parameter pack that is a pack expansion shall not expand a template parameter pack declared in the same template-parameter-list. [ Example:

    ...

    template               // error: Values expands template type parameter
      struct static_array;                          // pack T within the same template parameter list
    

    — end example ]

    So the code is ill-formed, even without the line foo(bar<0, 1L>{});.

    There is already a Clang bug report and a GCC bug report.

    0 讨论(0)
提交回复
热议问题