[Bug libstdc++/50641] [c++0x] is_convertible and is_constructible incorrectly require copy constructibility

2011-10-07 Thread daniel.kruegler at googlemail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50641

--- Comment #3 from Daniel Krügler daniel.kruegler at googlemail dot com 
2011-10-07 06:46:56 UTC ---
(In reply to comment #2)
 This looks like not-a-bug to me.

This refers to the traits implementation. I believe that the core language
should consider to remove the need for the temporary that is required in
heterogeneous copy-initialization, but this is out of scope of gcc.


[Bug libstdc++/50641] [c++0x] is_convertible and is_constructible incorrectly require copy constructibility

2011-10-07 Thread luto at mit dot edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50641

--- Comment #4 from Andy Lutomirski luto at mit dot edu 2011-10-07 06:57:01 
UTC ---
The problem I encountered that inspired this was:

#include type_traits
#include map

struct From
{
};

struct To
{
  To(const From ) {}
  To(const To ) = delete;
  void operator = (const To ) = delete;
};

int main()
{
  std::mapint, To m;
  m.insert(std::pairint, From(1, From()));
}

This works in 4.6.0 due to a different bug.  IMO it deserves to work -- the
implementation of map could move-construct the To object in place.  The
standard says explicitly that it's OK for To not to be CopyConstructible and,
indeed, this example works if I add:

To(const To ) {}

I defer to the experts (and the people who have a copy of the FDIS) to figure
out whether it's supposed to work.  N3242 says that From needs to be
convertible to To, but I'm not at all convinced that convertible means the
same thing as is_convertible.  Maybe if it's illegal I'll file a DR some day.

(N3242's section on map modifiers is woefully incomplete -- quite a few
functions are simply not there.  I hope the FDIS is better.)


[Bug libstdc++/50641] [c++0x] is_convertible and is_constructible incorrectly require copy constructibility

2011-10-07 Thread daniel.kruegler at googlemail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50641

--- Comment #5 from Daniel Krügler daniel.kruegler at googlemail dot com 
2011-10-07 07:13:50 UTC ---
(In reply to comment #4)
 N3242 says that From needs to be
 convertible to To, but I'm not at all convinced that convertible means the
 same thing as is_convertible.  Maybe if it's illegal I'll file a DR some 
 day.

It really means the same, implicit conversion is currently identical to
copy-initialization.

Note that the example here is addressed by LWG issue 2005 and it should work,
once the specification changes it is convertible requirement to a
corresponding is constructible requirement. The current P/R of LWG 2005 does
not contain the revised wording suggestion, though.


[Bug libstdc++/50641] [c++0x] is_convertible and is_constructible incorrectly require copy constructibility

2011-10-07 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50641

Paolo Carlini paolo.carlini at oracle dot com changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||INVALID

--- Comment #6 from Paolo Carlini paolo.carlini at oracle dot com 2011-10-07 
09:52:36 UTC ---
Thanks a lot Daniel. Thus, looks like it all boils down to just LWG 2005,
which we know well enough, I guess ;) and isn't a GCC issue.


[Bug libstdc++/50641] [c++0x] is_convertible and is_constructible incorrectly require copy constructibility

2011-10-06 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50641

Paolo Carlini paolo.carlini at oracle dot com changed:

   What|Removed |Added

 CC||daniel.kruegler at
   ||googlemail dot com

--- Comment #1 from Paolo Carlini paolo.carlini at oracle dot com 2011-10-06 
23:44:32 UTC ---
Daniel, can you help triaging this?


[Bug libstdc++/50641] [c++0x] is_convertible and is_constructible incorrectly require copy constructibility

2011-10-06 Thread daniel.kruegler at googlemail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50641

--- Comment #2 from Daniel Krügler daniel.kruegler at googlemail dot com 
2011-10-07 05:36:02 UTC ---
1) The outcome of is_constructible is expected, because you cannot construct
From from To, the actually wanted test would have been 

static_assert(std::is_constructibleTo, From::value, not constructible);

and this is correctly accepted.

2) The outcome of is_convertible is expected, because this traits is just a
trait to test for copy-initialization. Just add the line

To t2 = createFrom();

to your test function and this will fail too:

error: use of deleted function 'To::To(const To)

This is expected because the current language requires that a temporary of the
target type To will be created which is than moved/copied into the final To
object. Alas, this must fail, because To does not have any copy constructor not
move constructor.

This looks like not-a-bug to me.