This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/15339] New: function call error
- From: "MichaelLi8195 at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 May 2004 15:03:04 -0000
- Subject: [Bug c++/15339] New: function call error
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
//*******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