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

bangerth at dealii dot org gcc-bugzilla@gcc.gnu.org
Fri Jul 18 22:25:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: Odd error message with dynamically sized template arg
                    printing
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bangerth at dealii dot org
                CC: gcc-bugs at gcc dot gnu dot org,gdr at gcc dot gnu dot
                    org

Extracted from PR 6785: 
 
I guess this is totally irrelevant (because the code is invalid), but nevertheless: for this code 
------------------------------------------------- 
template <typename T> int  size(); 
template <int N>      void f(int (&)[N]); 
 
void g() { 
  int buf[size<int>()]; 
  f( buf ) ; 
} 
------------------------------------------------- 
we get the following error: 
tmp/gg> ../build-gcc/gcc-install/bin/c++ -c x.cc 
x.cc: In function `void g()': 
x.cc:6: error: no matching function for call to `f(int[size() [with T = int]()])' 
 
Note how we try to write the size of the array as an expression, which involves the 
call to a templated function, and where it tries to place the template arg when 
printing it. It is a little confusing to see the [with T=int] here, since T is nowhere referenced 
before or after, and the placing is odd. 
 
And then there is the duplicate () after the templates are printed. This can be seen here 
too: 
---------------------------------- 
int  size(); 
template <int N> void f(int (&)[N]); 
 
void g() { 
  int buf[size()]; 
  f( buf ) ; 
} 
------------------------------------- 
tmp/gg> ../build-gcc/gcc-install/bin/c++ -c x.cc 
x.cc: In function `void g()': 
x.cc:6: error: no matching function for call to `f(int[size()()])' 
 
I think that looks just cute ;-) 
 
W.



More information about the Gcc-bugs mailing list