This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P3
                 CC|                            |msebor at gcc dot gnu.org
           Severity|normal                      |minor

--- Comment #11 from Martin Sebor <msebor at gcc dot gnu.org> ---
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 [(<anonymous> + 1)])’
   f( buf ) ;
          ^
t.C:2:28: note: candidate: template<int N> void f(int (&)[N])
 template <int N>      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 <int N>      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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]