public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/56782] New: [C++11] Regression with empty pack expansions
@ 2013-03-29 13:44 daniel.kruegler at googlemail dot com
2013-03-29 13:51 ` [Bug c++/56782] [4.8/4.9 Regression] " paolo.carlini at oracle dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2013-03-29 13:44 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56782
Bug #: 56782
Summary: [C++11] Regression with empty pack expansions
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: daniel.kruegler@googlemail.com
As of gcc 4.8.0 the following code is now rejected when compiled with flags
-std=c++11 -Wall -W -pedantic
//---------------------------
template<class T>
T&& declval();
struct is_convertible_impl {
template<class T>
static void sink(T);
template<class T, class U, class = decltype(sink<U>(declval<T>()))>
static auto test(int) -> char;
template<class, class>
static auto test(...) -> char(&)[2];
};
template<class T, class U>
struct is_convertible : is_convertible_impl
{
static const bool value = sizeof(test<T, U>(0)) == 1;
};
template<bool, class>
struct enable_if {};
template<class T>
struct enable_if<true, T> { typedef T type; };
template<bool, class If, class Else>
struct conditional { typedef If type; };
template<class If, class Else>
struct conditional<false, If, Else> { typedef Else type; };
template<class...>
struct and_;
template<>
struct and_<>
{
static const bool value = true;
};
template<class P>
struct and_<P> : P
{
};
template<class P1, class P2>
struct and_<P1, P2> : conditional<P1::value, P2, P1>::type
{
};
template<class... T>
struct Tuple {
template<class... U,
class = typename enable_if<and_<
is_convertible<U, T>...
>::value, int>::type
>
Tuple(U&&...){}
};
static_assert(is_convertible<Tuple<int>, Tuple<int>>::value, "Ouch"); // OK
static_assert(is_convertible<Tuple<>, Tuple<>>::value, "Ouch"); // Error
//---------------------------
The diagnostics being:
"
Compilation finished with errors:
source.cpp:18:48: error: template instantiation depth exceeds maximum of 900
(use -ftemplate-depth= to increase the maximum) substituting 'template<class,
class> static char (& is_convertible_impl::test(...))[2] [with
<template-parameter-1-1> = Tuple<>; <template-parameter-1-2> = Tuple<>]'
static const bool value = sizeof(test<T, U>(0)) == 1;
^
source.cpp:55:5: recursively required from 'const bool is_convertible<Tuple<>,
Tuple<> >::value'
source.cpp:55:5: required from 'const bool is_convertible<Tuple<>, Tuple<>
>::value'
source.cpp:64:49: required from here
source.cpp:18:48: error: no matching function for call to
'is_convertible<Tuple<>, Tuple<> >::test(int)'
source.cpp:18:48: note: candidates are:
source.cpp:9:15: note: template<class T, class U, class> static char
is_convertible_impl::test(int)
static auto test(int) -> char;
^
source.cpp:9:15: note: template argument deduction/substitution failed:
source.cpp:12:15: note: template<class, class> static char (&
is_convertible_impl::test(...))[2]
static auto test(...) -> char(&)[2];
^
source.cpp:12:15: note: substitution of deduced template arguments resulted in
errors seen above
source.cpp:64:1: error: non-constant condition for static assertion
static_assert(is_convertible<Tuple<>, Tuple<>>::value, "Ouch"); // Error
^
source.cpp:64:1: error: the value of 'is_convertible<Tuple<>, Tuple<> >::value'
is not usable in a constant expression
source.cpp:18:21: note: 'is_convertible<Tuple<>, Tuple<> >::value' was not
initialized with a constant expression
static const bool value = sizeof(test<T, U>(0)) == 1;
^
"
The code is accepted with gcc 4.7.2 and with Clang 3.2.
It seems that for empty expansions the compiler erroneously does enter into the
actually empty expansion:
is_convertible<U, T>...
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/56782] [4.8/4.9 Regression] Regression with empty pack expansions
2013-03-29 13:44 [Bug c++/56782] New: [C++11] Regression with empty pack expansions daniel.kruegler at googlemail dot com
@ 2013-03-29 13:51 ` paolo.carlini at oracle dot com
2013-03-29 17:59 ` jason at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-03-29 13:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56782
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-03-29
CC| |jason at gcc dot gnu.org
Summary|[C++11] Regression with |[4.8/4.9 Regression]
|empty pack expansions |Regression with empty pack
| |expansions
Ever Confirmed|0 |1
--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-03-29 13:51:01 UTC ---
Confirmed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/56782] [4.8/4.9 Regression] Regression with empty pack expansions
2013-03-29 13:44 [Bug c++/56782] New: [C++11] Regression with empty pack expansions daniel.kruegler at googlemail dot com
2013-03-29 13:51 ` [Bug c++/56782] [4.8/4.9 Regression] " paolo.carlini at oracle dot com
@ 2013-03-29 17:59 ` jason at gcc dot gnu.org
2013-05-14 14:53 ` dodji at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2013-03-29 17:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56782
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dodji at gcc dot gnu.org
Depends on| |53609
--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> 2013-03-29 17:59:18 UTC ---
This seems to be an issue with Dodji's patch for bug 53609; we aren't using
PACK_EXPANSION_EXTRA_ARGS for the partial instantiation of the tuple
constructor, but we should be.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/56782] [4.8/4.9 Regression] Regression with empty pack expansions
2013-03-29 13:44 [Bug c++/56782] New: [C++11] Regression with empty pack expansions daniel.kruegler at googlemail dot com
2013-03-29 13:51 ` [Bug c++/56782] [4.8/4.9 Regression] " paolo.carlini at oracle dot com
2013-03-29 17:59 ` jason at gcc dot gnu.org
@ 2013-05-14 14:53 ` dodji at gcc dot gnu.org
2013-05-15 13:26 ` rguenth at gcc dot gnu.org
2013-05-15 14:47 ` dodji at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: dodji at gcc dot gnu.org @ 2013-05-14 14:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56782
Dodji Seketeli <dodji at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |dodji at gcc dot gnu.org
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/56782] [4.8/4.9 Regression] Regression with empty pack expansions
2013-03-29 13:44 [Bug c++/56782] New: [C++11] Regression with empty pack expansions daniel.kruegler at googlemail dot com
` (2 preceding siblings ...)
2013-05-14 14:53 ` dodji at gcc dot gnu.org
@ 2013-05-15 13:26 ` rguenth at gcc dot gnu.org
2013-05-15 14:47 ` dodji at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-05-15 13:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56782
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.8.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/56782] [4.8/4.9 Regression] Regression with empty pack expansions
2013-03-29 13:44 [Bug c++/56782] New: [C++11] Regression with empty pack expansions daniel.kruegler at googlemail dot com
` (3 preceding siblings ...)
2013-05-15 13:26 ` rguenth at gcc dot gnu.org
@ 2013-05-15 14:47 ` dodji at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: dodji at gcc dot gnu.org @ 2013-05-15 14:47 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56782
--- Comment #3 from Dodji Seketeli <dodji at gcc dot gnu.org> ---
A candidate patch was sent to
http://gcc.gnu.org/ml/gcc-patches/2013-05/msg00841.html for this.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-05-15 14:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-29 13:44 [Bug c++/56782] New: [C++11] Regression with empty pack expansions daniel.kruegler at googlemail dot com
2013-03-29 13:51 ` [Bug c++/56782] [4.8/4.9 Regression] " paolo.carlini at oracle dot com
2013-03-29 17:59 ` jason at gcc dot gnu.org
2013-05-14 14:53 ` dodji at gcc dot gnu.org
2013-05-15 13:26 ` rguenth at gcc dot gnu.org
2013-05-15 14:47 ` dodji at gcc dot gnu.org
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).