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

            Bug ID: 57248
           Summary: string parameter to constexpr functions
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sutambe at yahoo dot com

Created attachment 30098
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30098&action=edit
compiler output

g++ 4.9 spits out an internal error on the following code.

#include <tuple>
constexpr bool strmatch(const char *s1, const char *s2)
{
  return (*s1==*s2) ? 
            (*s1=='\0') ? 
               true
               : strmatch(s1+1, s2+1) 
            : false;
}

template <unsigned N>
constexpr int index(const char (&array)[N])
{
  return strmatch(array, "m0") ? 0 : -1;
}

template<unsigned N>
constexpr int extract(const std::tuple<int, int> & t1, const char (&array)[N])
{
  return std::get<index(array)>(t1);
}

int main(void)
{
  constexpr int i = strmatch("m0", "m0");  // OK
  constexpr int j = index("m0");  // OK
  constexpr int k = extract(std::make_tuple(10, 20), "m0"); // compiler fault

  return 0;
}


Configuration:
==============================
COLLECT_GCC=g++49
COLLECT_LTO_WRAPPER=/project/mySVN/gcc-4.9-20130421/libexec/gcc/i686-pc-linux-gnu/4.9.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ./configure --prefix=/project/mySVN/gcc-4.9-20130421
--with-mpfr=/project/mpfr-3.0.0 --with-gmp=/project/gmp-4.3.2
--with-mpc=/project/mpc-0.8.2 --enable-languages=c,cpp --enable-lto
--enable-languages=c --enable-languages=c++
Thread model: posix
gcc version 4.9.0 20130421 (experimental) (GCC)

Reply via email to