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

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).