Earlier today I tried to compile code similar to:
class example
{
public:
example(const char (&in_data)[6]);
};
example foo()
{
return "ABCDE";
}
On GCC, and it complained about there being no conversion to example on the return line. I was able to initialize objects of type example in other places with code such as
example bar("ABCDE");
just fine. All this worked fine when compiled in VS2010 as well.
Now, my question is, should this have worked, or is this some visual studio compiler extension? It seems to me that this should work due to the non-explicit constructor…
I don’t have the exact error message right now because I’m not at work, but it’s really bothering me.
I can’t see any reason why the implicit conversion shouldn’t work. Trying with gcc, clang, and EDG, only gcc fails. I’d guess this is a gcc error. That said, gcc seems to be keen to create a
char const*out of an array reference. This codeyields this error: