From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3598 invoked by alias); 2 Aug 2009 19:44:03 -0000 Received: (qmail 3578 invoked by uid 48); 2 Aug 2009 19:43:50 -0000 Date: Sun, 02 Aug 2009 19:44:00 -0000 Subject: [Bug c++/40944] New: [C++0x] rejects well-formed code: SFINAE, decltype, function call X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "s dot gesemann at gmail dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2009-08/txt/msg00070.txt.bz2 I think the following code is well-formed and should compile with the -std=c++0x switch: #include template struct make { static T&& it(); }; template struct exists { typedef R type; }; template< typename Func, typename T > void bar(T const& x, typename exists< int, decltype( make::it()(make::it()) ) // SFINAE! >::type = 0 ) { std::cout << "bar-1\n"; } template< typename Func > void bar(...) { std::cout << "bar-2\n"; } int main() { bar(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