[Warning] When passing const reference and default value
Mathieu Malaterre
mmalater@nycap.rr.com
Mon Nov 1 22:09:00 GMT 2004
Hello,
I was just wondering should the following code (*) produce a warning
when being compiled or not? I would tend to say yes, it should. If not
could someone explain me how the compiler could produce a string
reference out of the default const char * value ?
Thanks
Mathieu
(*)
#include <string>
#include <iostream>
void foo(std::string const & s = "bar" )
{
std::cout << s << std::endl;
}
int main()
{
foo( );
return 0;
}
//////////////////
// compilation line:
g++ -W -Wall -pedantic warn.cxx
More information about the Gcc
mailing list