public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57248] New: string parameter to constexpr functions
@ 2013-05-10 23:26 sutambe at yahoo dot com
  2013-05-11  0:21 ` [Bug c++/57248] " paolo.carlini at oracle dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: sutambe at yahoo dot com @ 2013-05-10 23:26 UTC (permalink / raw)
  To: gcc-bugs

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)


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-10-22  9:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-10 23:26 [Bug c++/57248] New: string parameter to constexpr functions sutambe at yahoo dot com
2013-05-11  0:21 ` [Bug c++/57248] " paolo.carlini at oracle dot com
2013-05-23 19:07 ` sutambe at yahoo dot com
2013-05-23 21:23 ` daniel.kruegler at googlemail dot com
2013-05-23 22:44 ` paolo.carlini at oracle dot com
2014-09-05 10:51 ` paolo.carlini at oracle dot com
2014-09-05 11:02 ` paolo.carlini at oracle dot com
2014-10-02 20:40 ` daniel.kruegler at googlemail dot com
2014-10-03 20:41 ` sutambe at yahoo dot com
2014-10-03 20:47 ` daniel.kruegler at googlemail dot com
2014-10-22  9:30 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).