[Bug c++/71007] Divergence between treatment of char[0] between OR (=> SFINAE failure) and diagnostic printing (no failure)

2021-08-17 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71007

Andrew Pinski  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=24663

--- Comment #4 from Andrew Pinski  ---
This is also related to PR 24663.

[Bug c++/71007] Divergence between treatment of char[0] between OR (=> SFINAE failure) and diagnostic printing (no failure)

2018-09-13 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71007

Eric Gallager  changed:

   What|Removed |Added

 CC||dmalcolm at gcc dot gnu.org,
   ||dodji at gcc dot gnu.org

--- Comment #3 from Eric Gallager  ---
cc-ing diagnostics maintainers

[Bug c++/71007] Divergence between treatment of char[0] between OR (=> SFINAE failure) and diagnostic printing (no failure)

2017-08-21 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71007

Eric Gallager  changed:

   What|Removed |Added

   Keywords||compile-time-hog,
   ||diagnostic
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-08-21
 CC||egallager at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #2 from Eric Gallager  ---
(In reply to Johannes Schaub from comment #0)
> The following is supposed to tell the user that char[0] is an invalid type,
> during diagnostic printing. But instead, it infinitely recurses up to
> SIZE_MAX or something during printing the diagnostic message, eventually
> crashing
> 
>#include 
>#include 
> 
>template
>auto ignore_n(std::integer_sequence) {
> return std::make_tuple((I, std::ignore)...);
>}
> 
>template
>auto function(Ts... ts)
>   -> decltype((std::tuple_cat(
>
> ignore_n(std::make_index_sequence  
> ()),
> std::tuple()) = std::forward_as_tuple(ts...)),
> void())
>{
>
>}
> 
>int main() {
>   function(2);
>   function(1, 2, 3);
>}
> 

This un-reduced version was taking forever to compile, so I had to kill it
before it could crash:

$ /usr/local/bin/g++ -c -Wall -Wextra -pedantic -time -ftime-report 71007.cc
71007.cc: In function ‘int main()’:
71007.cc:19:12: error: no matching function for call to ‘function(int)’
  function(2);
^
71007.cc:10:6: note: candidate: ‘template decltype
((std::tuple_cat(ignore_n(typename std::_Make_integer_sequence::__type>::make_index_sequence()), std::tuple())=
std::forward_as_tuple(function::ts ...), void())) function(Ts ...)’
 auto function(Ts... ts)
  ^~~~
71007.cc:10:6: note:   template argument deduction/substitution failed:
71007.cc: In substitution of ‘template decltype
((std::tuple_cat(ignore_n(typename std::_Make_integer_sequence::__type>::make_index_sequence()), std::tuple())=
std::forward_as_tuple(function::ts ...), void())) function(Ts ...) [with Ts =
{int}]’:
71007.cc:19:12:   required from here
71007.cc:12:42: warning: ISO C++ forbids zero-size array [-Wpedantic]
ignore_n(std::make_index_sequence
  ()),
  ^~
^C
$

(In reply to Johannes Schaub from comment #1)
> Sorry, forgot to actually add the code of the reduced testcase:
> 
>template
>void f(char(&)[N])
>{ }
> 
>int main() {
>   char x[1];
>   f(x);
>}

Confirmed:

$ /usr/local/bin/g++ -c -Wall -Wextra -pedantic 71007_reduced.cc
71007_reduced.cc: In function ‘int main()’:
71007_reduced.cc:7:4: error: no matching function for call to ‘f(char [1])’
 f(x);
^
71007_reduced.cc:2:6: note: candidate: ‘template void f(char
(&)[N])’
 void f(char(&)[N])
  ^
71007_reduced.cc:2:6: note:   template argument deduction/substitution failed:
71007_reduced.cc:1:17: warning: ISO C++ forbids zero-size array [-Wpedantic]
 template
 ^~~~
$

Weird that the underlining here points to the typename before T rather than the
actual array size.

[Bug c++/71007] Divergence between treatment of char[0] between OR (=> SFINAE failure) and diagnostic printing (no failure)

2016-05-08 Thread schaub.johannes at googlemail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71007

--- Comment #1 from Johannes Schaub  ---
Sorry, forgot to actually add the code of the reduced testcase:

   template
   void f(char(&)[N])
   { }

   int main() {
  char x[1];
  f(x);
   }