[Bug c++/11582] Odd error message with dynamically sized template arg printing

2021-08-23 Thread bangerth at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=11582

Wolfgang Bangerth  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|NEW |RESOLVED

--- Comment #13 from Wolfgang Bangerth  ---
Sure, good enough. I think `' isn't quite correct: it's a
variably-sized type, so the size can not be determined at compile time. This is
the part that is missing from the error message. But I don't think it's
worthwhile keeping the report open.

[Bug c++/11582] Odd error message with dynamically sized template arg printing

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

--- Comment #12 from Andrew Pinski  ---
Since GCC 11 we produce:
: In function 'void g()':
:7:4: error: no matching function for call to 'f(int [])'
7 |   f( buf ) ;
  |   ~^~~
:3:28: note: candidate: 'template void f(int (&)[N])'
3 | template   void f(int (&)[N]);
  |^
:3:28: note:   template argument deduction/substitution failed:
:7:4: note:   variable-sized array type 'long int' is not a valid
template argument
7 |   f( buf ) ;
  |   ~^~~

GCC 11 removes the ( + 1) part and just changes it to be
.

Is this warning good now?

[Bug c++/11582] Odd error message with dynamically sized template arg printing

2017-01-11 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=11582

Martin Sebor  changed:

   What|Removed |Added

   Priority|P2  |P3
 CC||msebor at gcc dot gnu.org
   Severity|normal  |minor

--- Comment #11 from Martin Sebor  ---
Today's trunk of GCC 7 prints the following.  Since there doesn't appear to be
a "correct" way to print the function signature (although several attempts seem
to have been made none has been found since 2003), if the bug is to stay open,
I think its priority and importance should be lower.  Setting P3 and Minor.

t.C: In function ‘void g()’:
t.C:6:10: error: no matching function for call to ‘f(int [( + 1)])’
   f( buf ) ;
  ^
t.C:2:28: note: candidate: template void f(int (&)[N])
 template   void f(int (&)[N]);
^
t.C:2:28: note:   template argument deduction/substitution failed:
t.C:6:10: note:   variable-sized array type ‘long int’ is not a valid template
argument
   f( buf ) ;
  ^

The messages printed by some other compilers are below for reference. 
Personally, I think the Visual Studio error looks quite good.

Clang 3.8:
t.C:6:3: error: no matching function for call to 'f'
  f( buf ) ; 
  ^
t.C:2:28: note: candidate template ignored: could not match 'int' against 'int'
template   void f(int (&)[N]); 
   ^

IBM XLC++:
"t.C", line 2.28: 1540-1173 (S) "int (&)[]" is not a valid parameter type.
"t.C", line 6.3: 1540-0700 (I) The previous message was produced while
processing "f<0>".

Intel ICC 17:
error: no instance of function template "f" matches the argument list
note: this candidate was rejected because at least one template argument could
not be deduced

Microsoft Visual Studio:
error C2672: 'f': no matching overloaded function found
source_file.cpp(6): error C2784: 'void f(int (&)[N])': could not deduce
template argument for 'int (&)[N]' from 'int ['function']'
source_file.cpp(2): note: see declaration of 'f'

Oracle Solaris Studio 12.4:
"t.C", line 5: Error: An integer constant expression is required within the
array subscript operator.

[Bug c++/11582] Odd error message with dynamically sized template arg printing

2013-04-22 Thread gdr at gcc dot gnu.org


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



--- Comment #8 from Gabriel Dos Reis gdr at gcc dot gnu.org 2013-04-22 
10:10:36 UTC ---

(In reply to comment #7)

 The '[(((sizetype)anonymous) + 1)]' is just awful. If we don't know the

 actual type there, that is int [size()], then we should just print 'int []'

 or 'int [size_t]' or something similar to denote a VLA.

 

 Surprisingly, Clang++ is even more confused:

 

 test.cc:6:3: error: no matching function for call to 'f'

   f( buf ) ; 

   ^

 test.cc:2:28: note: candidate template ignored: could not match 'int' against

 'int'

 template int N  void f(int ()[N]); 

^

 test.cc:13:3: error: no matching function for call to 'f'

   f( buf ) ; 

   ^

 test.cc:2:28: note: candidate template ignored: could not match 'int' against

 'int'

 template int N  void f(int ()[N]); 

^



Printing int[] or int[size_t] would be confusing too. 



Yes, Clang is not the gold standard.


[Bug c++/11582] Odd error message with dynamically sized template arg printing

2013-04-22 Thread manu at gcc dot gnu.org

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

--- Comment #9 from Manuel López-Ibáñez manu at gcc dot gnu.org 2013-04-22 
10:38:05 UTC ---
(In reply to comment #8)
 Printing int[] or int[size_t] would be confusing too. 

More confusing than int[(((sizetype)anonymous) + 1)] ?

What about?

t7881.cc: In function ‘void g()’:
t7881.cc:6:10: error: no matching function for call to ‘f(int
[{variable-length}])’
t7881.cc:6:10: note: candidate is:
t7881.cc:2:23: note: templateint N void f(int ()[N])
t7881.cc:2:23: note:   template argument deduction/substitution failed:
t7881.cc:6:10: note:   variable-sized array type is not a valid template
argument

[Bug c++/11582] Odd error message with dynamically sized template arg printing

2013-04-22 Thread gdr at gcc dot gnu.org

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

--- Comment #10 from Gabriel Dos Reis gdr at gcc dot gnu.org 2013-04-23 
03:45:56 UTC ---
(In reply to comment #9)
 (In reply to comment #8)
  Printing int[] or int[size_t] would be confusing too. 
 
 More confusing than int[(((sizetype)anonymous) + 1)] ?
 
 What about?
 
 t7881.cc: In function ‘void g()’:
 t7881.cc:6:10: error: no matching function for call to ‘f(int
 [{variable-length}])’
 t7881.cc:6:10: note: candidate is:
 t7881.cc:2:23: note: templateint N void f(int ()[N])
 t7881.cc:2:23: note:   template argument deduction/substitution failed:
 t7881.cc:6:10: note:   variable-sized array type is not a valid template
 argument

Remember that an array type as a function parameter is equivalent to a
pointer type.

[Bug c++/11582] Odd error message with dynamically sized template arg printing

2013-04-19 Thread manu at gcc dot gnu.org

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

Manuel López-Ibáñez manu at gcc dot gnu.org changed:

   What|Removed |Added

 CC||manu at gcc dot gnu.org

--- Comment #7 from Manuel López-Ibáñez manu at gcc dot gnu.org 2013-04-19 
17:13:38 UTC ---
The '[(((sizetype)anonymous) + 1)]' is just awful. If we don't know the
actual type there, that is int [size()], then we should just print 'int []'
or 'int [size_t]' or something similar to denote a VLA.

Surprisingly, Clang++ is even more confused:

test.cc:6:3: error: no matching function for call to 'f'
  f( buf ) ; 
  ^
test.cc:2:28: note: candidate template ignored: could not match 'int' against
'int'
template int N  void f(int ()[N]); 
   ^
test.cc:13:3: error: no matching function for call to 'f'
  f( buf ) ; 
  ^
test.cc:2:28: note: candidate template ignored: could not match 'int' against
'int'
template int N  void f(int ()[N]); 
   ^

[Bug c++/11582] Odd error message with dynamically sized template arg printing

2012-02-01 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11582

--- Comment #6 from Andrew Pinski pinskia at gcc dot gnu.org 2012-02-02 
00:30:07 UTC ---
t788.cc: In function ‘void g()’:
t788.cc:6:10: error: no matching function for call to ‘f(int
[(((sizetype)anonymous) + 1)])’
t788.cc:6:10: note: candidate is:
t788.cc:2:28: note: templateint N void f(int ()[N])
t788.cc:2:28: note:   template argument deduction/substitution failed:
t788.cc:6:10: note:   variable-sized array type ‘int [(((sizetype)anonymous)
+ 1)]’ is not a valid template argument

And
t7881.cc: In function ‘void g()’:
t7881.cc:6:10: error: no matching function for call to ‘f(int
[(((sizetype)anonymous) + 1)])’
t7881.cc:6:10: note: candidate is:
t7881.cc:2:23: note: templateint N void f(int ()[N])
t7881.cc:2:23: note:   template argument deduction/substitution failed:
t7881.cc:6:10: note:   variable-sized array type ‘int [(((sizetype)anonymous)
+ 1)]’ is not a valid template argument