http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59879

            Bug ID: 59879
           Summary: arrays in return statements or default arguments decay
                    too early
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: st at quanttec dot com

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();
         ^

Reply via email to