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

* [Bug c++/42539] C++0x: I tried to implement is_explicitly_convertible, but all I got was this lousy ICE
  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 ` 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
  2 siblings, 0 replies; 4+ messages in thread
From: d dot frey at gmx dot de @ 2009-12-29 15:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from d dot frey at gmx dot de  2009-12-29 15:05 -------
Note that the code is actually quite broken, the main problem which causes the
ICE is:

decltype( impl::select< From, To > )

which should read something like:

decltype( impl::select< From, To >() )

I meanwhile have a working implementation of is_explicitly_convertible for GCC
4.4.2 (in case someone is interested), so this bug is not a big problem, but
since it is an ICE, one might still want to fix it :)


-- 


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


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

* [Bug c++/42539] C++0x: I tried to implement is_explicitly_convertible, but all I got was this lousy ICE
  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
  2 siblings, 0 replies; 4+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-12-29 15:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from paolo dot carlini at oracle dot com  2009-12-29 15:05 -------
This doesn't crash in mainline, and I'm pretty sure Jason doesn't mean to fix
this kind of problem in 4_4-branch at this late time in the branch. I'm Cc-ing
him, anyway, because in mainline the first two assertions fail (I don't know if
that was intended, I didn't study the actual implementation, in case, please
just close it, as worksforme).


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu dot org


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


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

* [Bug c++/42539] C++0x: I tried to implement is_explicitly_convertible, but all I got was this lousy ICE
  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
  2 siblings, 0 replies; 4+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-12-29 15:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from paolo dot carlini at oracle dot com  2009-12-29 15:08 -------
Ah, ok, read the other message in the audit trail, we can close this.

Do you have a copyright assignment on file? In that case, your contribution is
certainly welcome, please send your implementation to the libstdc++ mailing
list, in the proper format, try to follow the stylistic conventions, etc, of
course.


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
      Known to work|                            |4.5.0
         Resolution|                            |WORKSFORME


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