public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/40595] New: ICE trying to use sfinae with variadic template pack expansion
@ 2009-06-29 18:44 jwakely dot gcc at gmail dot com
2009-06-30 9:53 ` [Bug c++/40595] " jwakely dot gcc at gmail dot com
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: jwakely dot gcc at gmail dot com @ 2009-06-29 18:44 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1489 bytes --]
template<int N>
struct S
{
typedef int type;
};
template<typename T>
struct Get
{
static T get();
};
#ifdef BUG
# define ELLIPSIS ...
#else
# define ELLIPSIS
#endif
template<typename F>
struct B
{
template<typename ELLIPSIS Args>
typename S<sizeof( Get<F>::get() (Get<Args>::get() ELLIPSIS) )>::type
f(Args&& ELLIPSIS a);
};
struct X
{
bool operator()(int) const;
};
int main()
{
B<X> b;
b.f(1);
}
jwakely@gcc16:~/src/tests$ g++ -std=c++0x -c pr.cc
jwakely@gcc16:~/src/tests$ g++ -std=c++0x -c pr.cc -DBUG
pr.cc: In instantiation of B<X>:
pr.cc:35:10: instantiated from here
pr.cc:25:9: internal compiler error: in tsubst, at cp/pt.c:9733
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
The code compiles fine with a single template parameter, but not with a
parameter pack of size one.
I'm trying to use SFINAE to disable overloads when a function call expression
is invalid, which is needed to implement std::bind for C++0x
--
Summary: ICE trying to use sfinae with variadic template pack
expansion
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jwakely dot gcc at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40595
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/40595] ICE trying to use sfinae with variadic template pack expansion
2009-06-29 18:44 [Bug c++/40595] New: ICE trying to use sfinae with variadic template pack expansion jwakely dot gcc at gmail dot com
@ 2009-06-30 9:53 ` jwakely dot gcc at gmail dot com
2009-06-30 10:11 ` [Bug c++/40595] [C++0x] " paolo dot carlini at oracle dot com
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jwakely dot gcc at gmail dot com @ 2009-06-30 9:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from jwakely dot gcc at gmail dot com 2009-06-30 09:53 -------
(In reply to comment #0)
> I'm trying to use SFINAE to disable overloads when a function call expression
> is invalid, which is needed to implement std::bind for C++0x
N.B. the use of an invalid expression in a sizeof context is not valid in
C++03, but the SFINAE rules were extended to cover general expressions by n2634
so I believe the code is valid in C++0x (see 14.9.2 [temp.deduct] p8 in WP
n2914) and should result in a type deduction failure not a hard error.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40595
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/40595] [C++0x] ICE trying to use sfinae with variadic template pack expansion
2009-06-29 18:44 [Bug c++/40595] New: ICE trying to use sfinae with variadic template pack expansion jwakely dot gcc at gmail dot com
2009-06-30 9:53 ` [Bug c++/40595] " jwakely dot gcc at gmail dot com
@ 2009-06-30 10:11 ` paolo dot carlini at oracle dot com
2009-06-30 10:53 ` jwakely dot gcc at gmail dot com
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-06-30 10:11 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from paolo dot carlini at oracle dot com 2009-06-30 10:11 -------
Jon, are there any hopes for a temporary workaround for std::bind?
--
paolo dot carlini at oracle dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu dot org
Summary|ICE trying to use sfinae |[C++0x] ICE trying to use
|with variadic template pack |sfinae with variadic
|expansion |template pack expansion
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40595
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/40595] [C++0x] ICE trying to use sfinae with variadic template pack expansion
2009-06-29 18:44 [Bug c++/40595] New: ICE trying to use sfinae with variadic template pack expansion jwakely dot gcc at gmail dot com
2009-06-30 9:53 ` [Bug c++/40595] " jwakely dot gcc at gmail dot com
2009-06-30 10:11 ` [Bug c++/40595] [C++0x] " paolo dot carlini at oracle dot com
@ 2009-06-30 10:53 ` jwakely dot gcc at gmail dot com
2009-06-30 19:37 ` jason at gcc dot gnu dot org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jwakely dot gcc at gmail dot com @ 2009-06-30 10:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from jwakely dot gcc at gmail dot com 2009-06-30 10:52 -------
The basic problem is I've made std::result_of too good ;-)
My new result_of uses decltype to determine the exact result type of an
arbitrary function call, including resolving overloads based on whether the
callable object and arguments are lvalues or rvalues.
If you look at struct _Bind in include/tr1_impl/functional you will see it has
multiple overloads of operator() and __call() with different cv-qualifiers.
Those overloads are used to ensure the cv qualifiers of the functor _M_f are
the same as the cv qualifiers of the _Bind object, as required by
[func.bind.bind]. The return type of those overloads uses result_of, but that
involves forming invalid expressions e.g. when there is no const volatile
operator() on the functor type.
I can solve that by using sfinae to remove the overloads when the expression is
invalid, but this bug prevents it.
A temporary solution would be to remove the const and volatile overloads for
now. That will work for 99% of cases, and will pass most of the testsuite,
because users don't usually invoke const or volatile binders.
This would fail under that workaround:
void f(int);
auto const b = std::bind(f, 1);
b();
Another options would be to support the example above, but to fudge the
result_of so that it does not use the correct cv qualifiers. That would fail
for this case:
struct F {
char* operator() const;
int operator();
};
i.e. when the cv qualifiers of the function object are significant and affect
the result type of the function call operator. For that type, using result_of
with the wrong cv qualifiers would cause _Bind to fail, because it infers a
result tyep that is not convertible to the actual result of the call.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40595
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/40595] [C++0x] ICE trying to use sfinae with variadic template pack expansion
2009-06-29 18:44 [Bug c++/40595] New: ICE trying to use sfinae with variadic template pack expansion jwakely dot gcc at gmail dot com
` (2 preceding siblings ...)
2009-06-30 10:53 ` jwakely dot gcc at gmail dot com
@ 2009-06-30 19:37 ` jason at gcc dot gnu dot org
2009-06-30 19:45 ` jason at gcc dot gnu dot org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-06-30 19:37 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from jason at gcc dot gnu dot org 2009-06-30 19:36 -------
Subject: Bug 40595
Author: jason
Date: Tue Jun 30 19:36:36 2009
New Revision: 149117
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=149117
Log:
PR c++/40595
* pt.c (tsubst_pack_expansion): Handle unexpanded packs in an
EXPR_PACK_EXPANSION.
Added:
trunk/gcc/testsuite/g++.dg/cpp0x/variadic94.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/pt.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40595
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/40595] [C++0x] ICE trying to use sfinae with variadic template pack expansion
2009-06-29 18:44 [Bug c++/40595] New: ICE trying to use sfinae with variadic template pack expansion jwakely dot gcc at gmail dot com
` (3 preceding siblings ...)
2009-06-30 19:37 ` jason at gcc dot gnu dot org
@ 2009-06-30 19:45 ` jason at gcc dot gnu dot org
2009-06-30 19:49 ` jason at gcc dot gnu dot org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-06-30 19:45 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jason at gcc dot gnu dot org 2009-06-30 19:45 -------
Subject: Bug 40595
Author: jason
Date: Tue Jun 30 19:45:21 2009
New Revision: 149118
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=149118
Log:
PR c++/40595
* pt.c (tsubst_pack_expansion): Handle unexpanded packs in an
EXPR_PACK_EXPANSION.
Added:
branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/variadic94.C
- copied unchanged from r149117,
trunk/gcc/testsuite/g++.dg/cpp0x/variadic94.C
Modified:
branches/gcc-4_4-branch/gcc/cp/ChangeLog
branches/gcc-4_4-branch/gcc/cp/pt.c
branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40595
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/40595] [C++0x] ICE trying to use sfinae with variadic template pack expansion
2009-06-29 18:44 [Bug c++/40595] New: ICE trying to use sfinae with variadic template pack expansion jwakely dot gcc at gmail dot com
` (4 preceding siblings ...)
2009-06-30 19:45 ` jason at gcc dot gnu dot org
@ 2009-06-30 19:49 ` jason at gcc dot gnu dot org
2009-07-01 10:54 ` mikpe at it dot uu dot se
2009-07-01 20:02 ` jason at redhat dot com
7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-06-30 19:49 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from jason at gcc dot gnu dot org 2009-06-30 19:49 -------
Fixed for 4.4.1.
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.4.1
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40595
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/40595] [C++0x] ICE trying to use sfinae with variadic template pack expansion
2009-06-29 18:44 [Bug c++/40595] New: ICE trying to use sfinae with variadic template pack expansion jwakely dot gcc at gmail dot com
` (5 preceding siblings ...)
2009-06-30 19:49 ` jason at gcc dot gnu dot org
@ 2009-07-01 10:54 ` mikpe at it dot uu dot se
2009-07-01 20:02 ` jason at redhat dot com
7 siblings, 0 replies; 9+ messages in thread
From: mikpe at it dot uu dot se @ 2009-07-01 10:54 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from mikpe at it dot uu dot se 2009-07-01 10:53 -------
(In reply to comment #6)
> Fixed for 4.4.1.
This test case causes the same ICE in tsubst also with gcc-4.3.4.
After packporting the ICE fix, 4.3.4 instead fails with:
variadic94.C: In function 'int main()':
variadic94.C:32: sorry, unimplemented: call_expr cannot be mangled due to a
defect in the C++ ABI
Is this an inherent limitation in 4.3 or just another unfixed bug?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40595
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/40595] [C++0x] ICE trying to use sfinae with variadic template pack expansion
2009-06-29 18:44 [Bug c++/40595] New: ICE trying to use sfinae with variadic template pack expansion jwakely dot gcc at gmail dot com
` (6 preceding siblings ...)
2009-07-01 10:54 ` mikpe at it dot uu dot se
@ 2009-07-01 20:02 ` jason at redhat dot com
7 siblings, 0 replies; 9+ messages in thread
From: jason at redhat dot com @ 2009-07-01 20:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from jason at redhat dot com 2009-07-01 20:01 -------
Subject: Re: [C++0x] ICE trying to use sfinae with variadic
template pack expansion
On 07/01/2009 06:53 AM, mikpe at it dot uu dot se wrote:
> Is this an inherent limitation in 4.3 or just another unfixed bug?
I'm not planning to fix C++0x bugs in 4.3.
Jason
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40595
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-07-01 20:02 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-29 18:44 [Bug c++/40595] New: ICE trying to use sfinae with variadic template pack expansion jwakely dot gcc at gmail dot com
2009-06-30 9:53 ` [Bug c++/40595] " jwakely dot gcc at gmail dot com
2009-06-30 10:11 ` [Bug c++/40595] [C++0x] " paolo dot carlini at oracle dot com
2009-06-30 10:53 ` jwakely dot gcc at gmail dot com
2009-06-30 19:37 ` jason at gcc dot gnu dot org
2009-06-30 19:45 ` jason at gcc dot gnu dot org
2009-06-30 19:49 ` jason at gcc dot gnu dot org
2009-07-01 10:54 ` mikpe at it dot uu dot se
2009-07-01 20:02 ` jason at redhat 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).