* [Bug c++/59867] Template string literal loses first symbol
2014-01-17 22:42 [Bug c++/59867] New: Template string literal loses first symbol i-hate-registration at mailinator dot com
@ 2014-01-18 7:31 ` jakub at gcc dot gnu.org
2014-01-18 9:31 ` paolo.carlini at oracle dot com
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-01-18 7:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59867
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Comment on attachment 31880
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31880
Template string literal works somehow strange in this example
>#include <iostream>
>using namespace std;
>
>// constant
>template <class T, T x>
>struct meta_value {
> typedef meta_value type;
> typedef T value_type;
> static const T value = x;
>};
>
>// array
>template <class T, T... data>
>struct meta_array {
> typedef meta_array type;
> typedef T item_type;
>};
>
>// static array -> runtime array conversion utility
>template <class T>
>struct array_gen;
>
>template <class T, T... xs>
>struct array_gen<meta_array<T, xs...>> {
> static const T value[sizeof...(xs)];
>};
>
>template <class T, T... xs>
>const T array_gen<meta_array<T, xs...>>::value[sizeof...(xs)] = { xs... };
>
>// static string
>template <class T, T... xs>
>constexpr meta_array<T, xs...> operator "" _s() {
> static_assert(sizeof...(xs) == 3, "What's wrong with you?");
> //static_assert(sizeof...(xs) != 3, "What's wrong with you?");
> return meta_array<T, xs...>();
>}
>
>int main() {
> const char (& xs)[2] = array_gen<decltype("123"_s)>::value;
> for (auto & x : xs) cout << x << endl;
>}
>From gcc-bugs-return-440806-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Jan 18 07:34:03 2014
Return-Path: <gcc-bugs-return-440806-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 20309 invoked by alias); 18 Jan 2014 07:34:02 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 20269 invoked by uid 48); 18 Jan 2014 07:33:59 -0000
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/59867] Template string literal loses first symbol
Date: Sat, 18 Jan 2014 07:34:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jakub at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-59867-4-3Ji2Xr82b8@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-59867-4@http.gcc.gnu.org/bugzilla/>
References: <bug-59867-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-01/txt/msg01948.txt.bz2
Content-length: 478
http://gcc.gnu.org/bugzilla/show_bug.cgi?idY867
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
This looks just as a missed diagnostics of invalid source.
Both in C++11 and in n3690 there is in [over.literal]/5:
"The declaration of a literal operator template shall have an empty
parameter-declaration-clause and its template-parameter-list shall have a
single template-parameter that is a non-type template parameter pack (14.5.3)
with element type char."
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/59867] Template string literal loses first symbol
2014-01-17 22:42 [Bug c++/59867] New: Template string literal loses first symbol i-hate-registration at mailinator dot com
2014-01-18 7:31 ` [Bug c++/59867] " jakub at gcc dot gnu.org
@ 2014-01-18 9:31 ` paolo.carlini at oracle dot com
2014-01-18 9:38 ` paolo.carlini at oracle dot com
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-01-18 9:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59867
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-01-18
Ever confirmed|0 |1
--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Looks like we have a C++1y extension of the C++11 requirements on the
parameters in place (see toward the end of
cp_parser_template_declaration_after_export) which however we don't handle
correctly. I think Ed should clarify the intention and either tighten the
diagnostic in C++1y mode too or make sure this kind of code is handled
correctly (well, ideally, in C++11 mode we shouldn't provide the static_assert
message, just emit the parsing error)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/59867] Template string literal loses first symbol
2014-01-17 22:42 [Bug c++/59867] New: Template string literal loses first symbol i-hate-registration at mailinator dot com
2014-01-18 7:31 ` [Bug c++/59867] " jakub at gcc dot gnu.org
2014-01-18 9:31 ` paolo.carlini at oracle dot com
@ 2014-01-18 9:38 ` paolo.carlini at oracle dot com
2014-01-18 9:52 ` jakub at gcc dot gnu.org
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-01-18 9:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59867
--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> ---
In fact current clang accepts the code as a GNU extension and we don't ;)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/59867] Template string literal loses first symbol
2014-01-17 22:42 [Bug c++/59867] New: Template string literal loses first symbol i-hate-registration at mailinator dot com
` (2 preceding siblings ...)
2014-01-18 9:38 ` paolo.carlini at oracle dot com
@ 2014-01-18 9:52 ` jakub at gcc dot gnu.org
2014-01-18 10:07 ` paolo.carlini at oracle dot com
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-01-18 9:52 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59867
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |emsr at gcc dot gnu.org
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Ah, it looks like this is n3599
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3599.html added in
r198018. Couldn't find what is this state (if it is going to be in C++14,
C++17 or when?).
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/59867] Template string literal loses first symbol
2014-01-17 22:42 [Bug c++/59867] New: Template string literal loses first symbol i-hate-registration at mailinator dot com
` (3 preceding siblings ...)
2014-01-18 9:52 ` jakub at gcc dot gnu.org
@ 2014-01-18 10:07 ` paolo.carlini at oracle dot com
2014-01-18 17:54 ` i-hate-registration at mailinator dot com
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-01-18 10:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59867
--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> ---
I went through the formal motions passed in Bristol and Chicago and didn't see
it, thus shouldn't be in C++14. C++17 maybe, nothing is decided yet.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/59867] Template string literal loses first symbol
2014-01-17 22:42 [Bug c++/59867] New: Template string literal loses first symbol i-hate-registration at mailinator dot com
` (4 preceding siblings ...)
2014-01-18 10:07 ` paolo.carlini at oracle dot com
@ 2014-01-18 17:54 ` i-hate-registration at mailinator dot com
2014-01-19 17:06 ` 3dw4rd at verizon dot net
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: i-hate-registration at mailinator dot com @ 2014-01-18 17:54 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59867
--- Comment #7 from Username <i-hate-registration at mailinator dot com> ---
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.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/59867] Template string literal loses first symbol
2014-01-17 22:42 [Bug c++/59867] New: Template string literal loses first symbol i-hate-registration at mailinator dot com
` (5 preceding siblings ...)
2014-01-18 17:54 ` i-hate-registration at mailinator dot com
@ 2014-01-19 17:06 ` 3dw4rd at verizon dot net
2014-01-21 20:00 ` 3dw4rd at verizon dot net
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: 3dw4rd at verizon dot net @ 2014-01-19 17:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59867
--- Comment #10 from Ed Smith-Rowland <3dw4rd at verizon dot net> ---
Right now, -std=c++1y means anything after c++11. Does anyone have an idea
about what happens when C++14 and these other TSen actually come out?
I guess I was thinking as far as this extension is concerned:
1) It is left *on* for c++1y and gnu++1y for backward compatibility. Sigh.
2) It is *on* with gnu++14 as an extension.
3) It is *off* with c++14 for strict ANSI compatibility.
4) It is maybe on for c++17 and gnu++17 when & if it ever gets in.
We seem to have dynamically sized array (VLA) in this category as well.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/59867] Template string literal loses first symbol
2014-01-17 22:42 [Bug c++/59867] New: Template string literal loses first symbol i-hate-registration at mailinator dot com
` (6 preceding siblings ...)
2014-01-19 17:06 ` 3dw4rd at verizon dot net
@ 2014-01-21 20:00 ` 3dw4rd at verizon dot net
2014-06-27 21:03 ` 3dw4rd at verizon dot net
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: 3dw4rd at verizon dot net @ 2014-01-21 20:00 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59867
--- Comment #11 from Ed Smith-Rowland <3dw4rd at verizon dot net> ---
This may be related to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58781 -
another decltype user-defined literal bug.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/59867] Template string literal loses first symbol
2014-01-17 22:42 [Bug c++/59867] New: Template string literal loses first symbol i-hate-registration at mailinator dot com
` (7 preceding siblings ...)
2014-01-21 20:00 ` 3dw4rd at verizon dot net
@ 2014-06-27 21:03 ` 3dw4rd at verizon dot net
2014-06-27 21:03 ` 3dw4rd at verizon dot net
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: 3dw4rd at verizon dot net @ 2014-06-27 21:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59867
--- Comment #12 from Ed Smith-Rowland <3dw4rd at verizon dot net> ---
Created attachment 33019
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33019&action=edit
Patch 58781, 59867, 60249, ...
I think I got it.
Don't mess with the token stream.
PR C++/58781 - Unicode strings broken in a strange way
PR C++/59867 - Template string literal loses first symbol
PR C++/60249 - Compiler goes into semi-infinite loop with wrong usage of user
defined string literals
Plus I fixed an misleading error message for string literal operator templates
(not available in C++11).
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/59867] Template string literal loses first symbol
2014-01-17 22:42 [Bug c++/59867] New: Template string literal loses first symbol i-hate-registration at mailinator dot com
` (8 preceding siblings ...)
2014-06-27 21:03 ` 3dw4rd at verizon dot net
@ 2014-06-27 21:03 ` 3dw4rd at verizon dot net
2014-07-01 3:13 ` emsr at gcc dot gnu.org
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: 3dw4rd at verizon dot net @ 2014-06-27 21:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59867
--- Comment #13 from Ed Smith-Rowland <3dw4rd at verizon dot net> ---
Created attachment 33020
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33020&action=edit
Patch 58781, 59867, 60249, ...
I think I got it.
Don't mess with the token stream.
PR C++/58781 - Unicode strings broken in a strange way
PR C++/59867 - Template string literal loses first symbol
PR C++/60249 - Compiler goes into semi-infinite loop with wrong usage of user
defined string literals
Plus I fixed an misleading error message for string literal operator templates
(not available in C++11).
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/59867] Template string literal loses first symbol
2014-01-17 22:42 [Bug c++/59867] New: Template string literal loses first symbol i-hate-registration at mailinator dot com
` (9 preceding siblings ...)
2014-06-27 21:03 ` 3dw4rd at verizon dot net
@ 2014-07-01 3:13 ` emsr at gcc dot gnu.org
2014-07-01 5:31 ` emsr at gcc dot gnu.org
2014-07-01 5:33 ` emsr at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: emsr at gcc dot gnu.org @ 2014-07-01 3:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59867
--- Comment #14 from emsr at gcc dot gnu.org ---
Author: emsr
Date: Tue Jul 1 03:13:17 2014
New Revision: 212186
URL: https://gcc.gnu.org/viewcvs?rev=212186&root=gcc&view=rev
Log:
cp/
2014-06-28 Edward Smith-Rowland <3dw4rd@verizon.net>
PR c++/58781
PR c++/60249
PR c++/59867
* parser.c (cp_parser_userdef_string_literal()): Take a tree
not a cp_token*. (cp_parser_string_literal(): Don't hack
the token stream!
testsuite/
2014-06-28 Edward Smith-Rowland <3dw4rd@verizon.net>
PR c++/58781
PR c++/60249
PR c++/59867
* testsuite/g++.dg/cpp0x/pr58781.C: New.
* testsuite/g++.dg/cpp0x/pr60249.C: New.
* testsuite/g++.dg/cpp1y/pr59867.C: New.
Added:
trunk/gcc/testsuite/g++.dg/cpp0x/pr58781.C
trunk/gcc/testsuite/g++.dg/cpp0x/pr60249.C
trunk/gcc/testsuite/g++.dg/cpp1y/pr59867.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/parser.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/59867] Template string literal loses first symbol
2014-01-17 22:42 [Bug c++/59867] New: Template string literal loses first symbol i-hate-registration at mailinator dot com
` (10 preceding siblings ...)
2014-07-01 3:13 ` emsr at gcc dot gnu.org
@ 2014-07-01 5:31 ` emsr at gcc dot gnu.org
2014-07-01 5:33 ` emsr at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: emsr at gcc dot gnu.org @ 2014-07-01 5:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59867
--- Comment #15 from emsr at gcc dot gnu.org ---
Author: emsr
Date: Tue Jul 1 05:30:34 2014
New Revision: 212188
URL: https://gcc.gnu.org/viewcvs?rev=212188&root=gcc&view=rev
Log:
cp/
2014-06-28 Edward Smith-Rowland <3dw4rd@verizon.net>
PR c++/58781
PR c++/60249
PR c++/59867
* parser.c (cp_parser_userdef_string_literal()): Take a tree
not a cp_token*. (cp_parser_string_literal(): Don't hack
the token stream!
testsuite/
2014-06-28 Edward Smith-Rowland <3dw4rd@verizon.net>
PR c++/58781
PR c++/60249
PR c++/59867
* testsuite/g++.dg/cpp0x/pr58781.C: New.
* testsuite/g++.dg/cpp0x/pr60249.C: New.
* testsuite/g++.dg/cpp1y/pr59867.C: New.
Added:
branches/gcc-4_9-branch/gcc/testsuite/g++.dg/cpp0x/pr58781.C
branches/gcc-4_9-branch/gcc/testsuite/g++.dg/cpp0x/pr60249.C
branches/gcc-4_9-branch/gcc/testsuite/g++.dg/cpp1y/pr59867.C
Modified:
branches/gcc-4_9-branch/gcc/cp/ChangeLog
branches/gcc-4_9-branch/gcc/cp/parser.c
branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/59867] Template string literal loses first symbol
2014-01-17 22:42 [Bug c++/59867] New: Template string literal loses first symbol i-hate-registration at mailinator dot com
` (11 preceding siblings ...)
2014-07-01 5:31 ` emsr at gcc dot gnu.org
@ 2014-07-01 5:33 ` emsr at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: emsr at gcc dot gnu.org @ 2014-07-01 5:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59867
emsr at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #16 from emsr at gcc dot gnu.org ---
Fixed.
^ permalink raw reply [flat|nested] 14+ messages in thread