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

2014-01-17 Thread i-hate-registration at mailinator dot com
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 ) ,
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
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
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!

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

2014-01-18 Thread i-hate-registration at mailinator dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59867

--- Comment #7 from Username  ---
I've heard that it was previously expected to be in C++14, though it was
somehow forgotten, because the fix is quite small and one could currently do it
with a little bit of preprocessor/constexpr (MPLLIBS_STRING in
https://github.com/sabel83/mpllibs).

Nevertheless, compile-time strings are very useful (as it's shown in D), and
will be a part of standard sooner or later.