https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69059
Bug ID: 69059 Summary: [C++14] Invalid rejection of expression as not-a-constant-expression Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ldionne.2 at gmail dot com Target Milestone: --- The following code does not compile with GCC trunk (g++ 6.0.0 20151226 experimental): template <typename T> struct holder { T value; }; template <typename T> constexpr holder<char const*> make_holder_impl(T&& t) { return {static_cast<T&&>(t)}; } template <typename T> constexpr auto make_holder(T&& t) { return make_holder_impl(static_cast<T&&>(t)); } constexpr int my_strlen(char const* s) { int n = 0; while (*s++ != '\0') ++n; return n; } constexpr int len = my_strlen(make_holder("name").value); The error is [snip]/bin/g++ -pedantic -std=c++1y -W -Wall -Wextra -c ../test/worksheet.cpp ../test/worksheet.cpp:1221:30: in constexpr expansion of ‘my_strlen(make_holder<const char (&)[5]>("name").holder<const char*>::value)’ ../test/worksheet.cpp:1216:12: error: ‘t’ is not a constant expression while (*s++ != '\0') ^~~~ Live example: http://melpon.org/wandbox/permlink/77rNCLjwmz1P1xG2