public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/42539]  New: C++0x: I tried to implement is_explicitly_convertible, but all I got was this lousy ICE
@ 2009-12-29 14:28 d dot frey at gmx dot de
  2009-12-29 15:05 ` [Bug c++/42539] " d dot frey at gmx dot de
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: d dot frey at gmx dot de @ 2009-12-29 14:28 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3000 bytes --]

I tried to implement C++0x's std::is_explicitly_convertible, but decltype
crashes on my code with an internal compiler error. The code is:

#include <type_traits>

namespace my_std
{
  namespace impl
  {
    template< typename T > T make();

    template< typename From, typename To >
    decltype( From( make< To >() ), make< std::true_type >() ) select();

    template< typename From, typename To >
    std::false_type select();
  }

  template< typename From, typename To >
  struct is_explicitly_convertible
    : std::is_same< decltype( impl::select< From, To > ), std::true_type >
  {
  };
}

struct X
{
  X( double& );
  explicit X( int& );
};

#define STATIC_ASSERT( X ) static_assert( X, #X )

int main()
{
  STATIC_ASSERT(( my_std::is_explicitly_convertible< double&, X >::value ));
  STATIC_ASSERT(( my_std::is_explicitly_convertible< int&, X >::value ));
  STATIC_ASSERT(( !my_std::is_explicitly_convertible< void*, X >::value ));
}


Tested on GCC 4.3.3 (Ubuntu 9.04) and 4.4.2 (self-compiled), error messages:

frey@viasko::~/work/test/is_explicitly_convertible$ g++ --version
g++ (Ubuntu 4.3.3-5ubuntu4) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

frey@viasko::~/work/test/is_explicitly_convertible$ g++ -std=c++0x t.cc -o t
t.cc: In instantiation of ‘pwd::is_explicitly_convertible<double&, X>’:
t.cc:35:   instantiated from here
t.cc:21: internal compiler error: in finish_decltype_type, at
cp/semantics.c:4231
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.3/README.Bugs> for instructions.
frey@viasko:1:~/work/test/is_explicitly_convertible$ . ~/work/use_gcc.sh 
frey@viasko::~/work/test/is_explicitly_convertible$ g++ --version
g++ (GCC) 4.4.2
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

frey@viasko::~/work/test/is_explicitly_convertible$ g++ -std=c++0x t.cc -o t
t.cc: In instantiation of ‘pwd::is_explicitly_convertible<double&, X>’:
t.cc:35:   instantiated from here
t.cc:21: internal compiler error: in finish_decltype_type, at
cp/semantics.c:4689
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
frey@viasko:1:~/work/test/is_explicitly_convertible$ 

Regards, Daniel


-- 
           Summary: C++0x: I tried to implement is_explicitly_convertible,
                    but all I got was this lousy ICE
           Product: gcc
           Version: 4.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: d dot frey at gmx dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42539


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-12-29 15:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-29 14:28 [Bug c++/42539] New: C++0x: I tried to implement is_explicitly_convertible, but all I got was this lousy ICE d dot frey at gmx dot de
2009-12-29 15:05 ` [Bug c++/42539] " d dot frey at gmx dot de
2009-12-29 15:06 ` paolo dot carlini at oracle dot com
2009-12-29 15:09 ` paolo dot carlini at oracle 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).