g++ seems to decay arrays in return statements or default arguments too early. The following sample fails to compile with 4.8.2 and the current GIT master version of gcc but compiles cleanly in clang: -- struct Test { template <int N> Test(const char (&array)[N]) {} }; Test test() { return "test"; } void test2(Test arg = "test") {} int main() { test(); test2(); } -- g++ test.cpp test.cpp: In function ‘Test test()’: test.cpp:8:10: error: could not convert ‘(const char*)"test"’ from ‘const char*’ to ‘Test’ return "test"; ^ test.cpp: In function ‘int main()’: test.cpp:15:9: error: could not convert ‘(const char*)"test"’ from ‘const char*’ to ‘Test’ test2(); ^
Author: ppalka Date: Thu Dec 17 13:30:04 2015 New Revision: 231755 URL: https://gcc.gnu.org/viewcvs?rev=231755&root=gcc&view=rev Log: Fix wrong PR references PR c++/59878 -> PR c++/59879 Added: trunk/gcc/testsuite/g++.dg/conversion/pr59879.C Removed: trunk/gcc/testsuite/g++.dg/conversion/pr59878.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/testsuite/ChangeLog
Fixed in r231736.