public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/40944] New: [C++0x] rejects well-formed code: SFINAE, decltype, function call
@ 2009-08-02 19:44 s dot gesemann at gmail dot com
2009-08-04 12:51 ` [Bug c++/40944] " jwakely dot gcc at gmail dot com
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: s dot gesemann at gmail dot com @ 2009-08-02 19:44 UTC (permalink / raw)
To: gcc-bugs
I think the following code is well-formed and should compile with the
-std=c++0x switch:
#include <iostream>
template<typename T>
struct make { static T&& it(); };
template<typename R, typename... T>
struct exists { typedef R type; };
template< typename Func, typename T >
void bar(T const& x,
typename exists<
int,
decltype( make<Func>::it()(make<T const&>::it()) ) // SFINAE!
>::type = 0
) {
std::cout << "bar-1\n";
}
template< typename Func >
void bar(...) {
std::cout << "bar-2\n";
}
int main() {
bar<void(*)(int&)>(42);
}
I expect it to compile and print "bar-2". Instead, the compiler rejects the
code with the error
invalid initialization of reference >int&< with an expression of
type >const int<.
Cheers!
SG
--
Summary: [C++0x] rejects well-formed code: SFINAE, decltype,
function call
Product: gcc
Version: 4.4.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: s dot gesemann at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40944
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/40944] [C++0x] rejects well-formed code: SFINAE, decltype, function call
2009-08-02 19:44 [Bug c++/40944] New: [C++0x] rejects well-formed code: SFINAE, decltype, function call s dot gesemann at gmail dot com
@ 2009-08-04 12:51 ` jwakely dot gcc at gmail dot com
2009-08-16 12:48 ` s dot gesemann at gmail dot com
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jwakely dot gcc at gmail dot com @ 2009-08-04 12:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from jwakely dot gcc at gmail dot com 2009-08-04 12:35 -------
I think you're right that this is a bug, this is a slightly reduced testcase
showing the same error:
template<typename T>
struct make { static T&& it(); };
void (*pf)(int&) = 0;
template< typename T >
int bar(T const& x,
decltype( pf(make<T const&>::it()) )* = 0 // SFINAE!
) {
return 1;
}
int bar(...) {
return 0;
}
int main() {
return bar(42);
}
I think this should compile and return 0
--
jwakely dot gcc at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jwakely dot gcc at gmail dot
| |com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40944
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/40944] [C++0x] rejects well-formed code: SFINAE, decltype, function call
2009-08-02 19:44 [Bug c++/40944] New: [C++0x] rejects well-formed code: SFINAE, decltype, function call s dot gesemann at gmail dot com
2009-08-04 12:51 ` [Bug c++/40944] " jwakely dot gcc at gmail dot com
@ 2009-08-16 12:48 ` s dot gesemann at gmail dot com
2009-08-16 13:00 ` s dot gesemann at gmail dot com
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: s dot gesemann at gmail dot com @ 2009-08-16 12:48 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from s dot gesemann at gmail dot com 2009-08-16 12:48 -------
This is probably a related (SFINAE<->decltype) problem:
template<typename T>
struct meta {
static T&& m(); // make
static void s(T); // sink
};
// operator()(T&,int) available ?
template<typename T, typename = decltype( meta<T&>::m()(23) )>
int foo(T x) {
x(23);
return 1;
}
int foo(...) {
return 0;
}
int main() {
return foo(42);
}
As far as I can tell it should compile with -std=c++0x and return 0. Instead,
the compiler rejects the code.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40944
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/40944] [C++0x] rejects well-formed code: SFINAE, decltype, function call
2009-08-02 19:44 [Bug c++/40944] New: [C++0x] rejects well-formed code: SFINAE, decltype, function call s dot gesemann at gmail dot com
2009-08-04 12:51 ` [Bug c++/40944] " jwakely dot gcc at gmail dot com
2009-08-16 12:48 ` s dot gesemann at gmail dot com
@ 2009-08-16 13:00 ` s dot gesemann at gmail dot com
2009-11-03 16:21 ` jason at gcc dot gnu dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: s dot gesemann at gmail dot com @ 2009-08-16 13:00 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from s dot gesemann at gmail dot com 2009-08-16 13:00 -------
sorry, please disregard my previous comment. I accidentally used GCC 4.3.3
instead of GCC 4.4.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40944
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/40944] [C++0x] rejects well-formed code: SFINAE, decltype, function call
2009-08-02 19:44 [Bug c++/40944] New: [C++0x] rejects well-formed code: SFINAE, decltype, function call s dot gesemann at gmail dot com
` (2 preceding siblings ...)
2009-08-16 13:00 ` s dot gesemann at gmail dot com
@ 2009-11-03 16:21 ` jason at gcc dot gnu dot org
2009-11-03 17:11 ` jason at gcc dot gnu dot org
2009-11-03 18:49 ` jason at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-11-03 16:21 UTC (permalink / raw)
To: gcc-bugs
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |jason at gcc dot gnu dot org
|dot org |
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2009-11-03 16:21:06
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40944
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/40944] [C++0x] rejects well-formed code: SFINAE, decltype, function call
2009-08-02 19:44 [Bug c++/40944] New: [C++0x] rejects well-formed code: SFINAE, decltype, function call s dot gesemann at gmail dot com
` (3 preceding siblings ...)
2009-11-03 16:21 ` jason at gcc dot gnu dot org
@ 2009-11-03 17:11 ` jason at gcc dot gnu dot org
2009-11-03 18:49 ` jason at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-11-03 17:11 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from jason at gcc dot gnu dot org 2009-11-03 17:11 -------
Subject: Bug 40944
Author: jason
Date: Tue Nov 3 17:11:18 2009
New Revision: 153856
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153856
Log:
PR c++/40944
* call.c (initialize_reference): Add complain parm.
* typeck.c (convert_for_initialization): Pass it.
* decl.c (grok_reference_init): Likewise.
* cp-tree.h: Declare it.
Added:
trunk/gcc/testsuite/g++.dg/template/sfinae15.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/call.c
trunk/gcc/cp/cp-tree.h
trunk/gcc/cp/decl.c
trunk/gcc/cp/typeck.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40944
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/40944] [C++0x] rejects well-formed code: SFINAE, decltype, function call
2009-08-02 19:44 [Bug c++/40944] New: [C++0x] rejects well-formed code: SFINAE, decltype, function call s dot gesemann at gmail dot com
` (4 preceding siblings ...)
2009-11-03 17:11 ` jason at gcc dot gnu dot org
@ 2009-11-03 18:49 ` jason at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-11-03 18:49 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jason at gcc dot gnu dot org 2009-11-03 18:49 -------
Fixed for 4.5.
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.5.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40944
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-11-03 18:49 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-02 19:44 [Bug c++/40944] New: [C++0x] rejects well-formed code: SFINAE, decltype, function call s dot gesemann at gmail dot com
2009-08-04 12:51 ` [Bug c++/40944] " jwakely dot gcc at gmail dot com
2009-08-16 12:48 ` s dot gesemann at gmail dot com
2009-08-16 13:00 ` s dot gesemann at gmail dot com
2009-11-03 16:21 ` jason at gcc dot gnu dot org
2009-11-03 17:11 ` jason at gcc dot gnu dot org
2009-11-03 18:49 ` jason at gcc dot gnu dot 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).