public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15339] New: function call error
@ 2004-05-07 15:03 MichaelLi8195 at hotmail dot com
  2004-05-07 15:30 ` [Bug c++/15339] " bangerth at dealii dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 14+ messages in thread
From: MichaelLi8195 at hotmail dot com @ 2004-05-07 15:03 UTC (permalink / raw)
  To: gcc-bugs

//*******mytest.hpp******* 
#ifndef MYTEST_H 
#define MYTEST_H 
#include <iostream> 
#include <string> 
template<typename T>    //declaration 
void fun(T val, const std::string seperator); //error, change to 
                                         //seperator = " " , then it works well

template<typename T>    //definition 
void fun(T val, const std::string seperator = " ") 
{ 
    std::cout<<val<<seperator<<std::endl; 
} 
#endif 

//***********test.cpp********* 
#include "mytest.hpp" 
int main() 
{ 
   fun(10); 
}

g++ test.cpp -o test
and reads "test.cpp:4:error: no matching function for call to `fun(int)'".
I think the function should be resolved from its definition not its 
declaration the first one it encountered. It means that although no default 
argument is provided in function declaration, as long as it has one default in 
the definition, it should also work well.

-- 
           Summary: function call error
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: MichaelLi8195 at hotmail dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2004-07-13 20:14 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-07 15:03 [Bug c++/15339] New: function call error MichaelLi8195 at hotmail dot com
2004-05-07 15:30 ` [Bug c++/15339] " bangerth at dealii dot org
2004-05-07 16:36   ` llewelly
2004-05-07 15:37 ` bangerth at dealii dot org
2004-05-07 16:24   ` Gabriel Dos Reis
2004-05-07 16:24 ` gdr at integrable-solutions dot net
2004-05-07 16:36 ` llewelly at xmission dot com
2004-05-07 16:54 ` bangerth at dealii dot org
2004-05-08 16:29 ` giovannibajo at libero dot it
2004-05-08 16:32 ` [Bug c++/15339] [DR217] Adding default arguments to function templates in redeclartions should be forbidden giovannibajo at libero dot it
2004-05-09 14:19 ` MichaelLi8195 at hotmail dot com
2004-05-09 15:18 ` bangerth at dealii dot org
2004-07-13 20:13 ` giovannibajo at libero dot it
2004-07-13 20:14 ` giovannibajo at libero dot it

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).