g++ treats returned string literal as const char pointer not const char array
I'm seeing some odd behaviour when returning a string literal from a function that should perform an implicit conversion with g++ (version 4.7.3). Can anyone explain why the following code: #include <stdio.h> class Test { public: template <unsigned int N> Test(const char (&foo)[N]) { printf("Template const char array constructor\n"); } Test(char* foo) { printf("char* constructor\n"); } }; Test fn() { return "foo"; } int main() { Test t("bar"); Test u = fn(); return 0; } produces the result: Template const char array constructor char* constructor on g++? The surprising thing being that the char