[Bug c++/59867] New: Template string literal loses first symbol

i-hate-registration at mailinator dot com gcc-bugzilla@gcc.gnu.org
Fri Jan 17 22:42:00 GMT 2014


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

            Bug ID: 59867
           Summary: Template string literal loses first symbol
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: i-hate-registration at mailinator dot com

Created attachment 31880
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31880&action=edit
Template string literal works somehow strange in this example

Hi everyone,

When using a template string literal overload (template <class T, T... xs>) ,
for "123"_s, I get xs = {'2', '3'} instead of xs = {'1', '2', '3'}.

There's as minimal example as I could make in the attachment. When it's
compiled in its current way, it shows the following error:

> g++ -std=c++1y example.cpp -o example
example.cpp: In instantiation of ‘constexpr meta_array<T, xs ...>
operator""_s() [with T = char; T ...xs = {'2', '3'}]’:
example.cpp:40:44:   required from here
example.cpp:34:2: error: static assertion failed: What's wrong with you?
  static_assert(sizeof...(xs) == 3, "What's wrong with you?");
  ^

When I replace equality with inequality in static_assert:

> g++ -std=c++1y example.cpp -o example
example.cpp: In instantiation of ‘constexpr meta_array<T, xs ...>
operator""_s() [with T = char; T ...xs = {'1', '2', '3'}]’:
example.cpp:40:44:   required from here
example.cpp:35:2: error: static assertion failed: What's wrong with you?
  static_assert(sizeof...(xs) != 3, "What's wrong with you?");
  ^

As ""_s is used only once in the code and, I believe, there's no implicit way
it's called recursively, it looks like there's some kind of bug.

P.S. Thank you for the great work!


More information about the Gcc-bugs mailing list