[Bug libstdc++/33628] unary_function and pointer_to_unary_function issues with void template arguments

2008-03-09 Thread pcarlini at suse dot de


--- Comment #3 from pcarlini at suse dot de  2008-03-09 11:21 ---
I agree ;)


-- 

pcarlini at suse dot de changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||INVALID


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



[Bug libstdc++/33628] unary_function and pointer_to_unary_function issues with void template arguments

2008-03-08 Thread jwakely dot gcc at gmail dot com


--- Comment #2 from jwakely dot gcc at gmail dot com  2008-03-08 15:25 
---
(In reply to comment #0)
 // 1
 #include functional
 
 typedef int value_type;
 
 // void argument type
 template class std::unary_functionvoid, value_type;

eurgh, even more of an abomination than int f(void)  :-)

 template class std::pointer_to_unary_functionvoid, value_type;

This fails, correctly I think.  It's analogous to this illegal declaration:
  typedef void T;
  int f(T);

 // void return type
 template class std::unary_functionvalue_type, void;
 template class std::pointer_to_unary_functionvalue_type, void;

These are OK, aren't they?

 And more specific things:
 
 // 2
 #include functional
 void foo() { };
 
 // pointer_to_unary_function
 void test01()
 {
   typedef std::pointer_to_unary_functionvoid, void pfunc;
   pfunc p(foo);

this is invalid, foo is not a unary function so the number of parameters
doesn't match.  The declaration void f(void) is valid for C compatibility, but
that doesn't make it a unary function.
14.8.2para2 says type deduction can fail due to Attempting to create a
function type in which a parameter has a type of void.  That's discussing a
different situation, but the principle is the same. I couldn't find anything
more specific.

 // 3
 #include functional
 // unary_function
 struct void_unary : public std::unary_functionvoid, void
 { 
   typedef std::unary_functionvoid, void base_type;
   typedef base_type::Arg argument_type;
   typedef base_type::Result result_type;
 };

Hmm, I suppose this is legal, although ill-advised.

 Is this usage standards-conforming?

I think the declarations and typedefs are legal, but using them isn't
necessarily possible. So you can't assign foo to a unary_function, and you
couldn't define this member:
  Result void_unary::f(Arg);

Thankfully the void f(void) syntax is not valid in templates, because there's
no need for C compatibility in template code.

I don't think this is a bug.


-- 

jwakely dot gcc at gmail dot com changed:

   What|Removed |Added

 CC||jwakely dot gcc at gmail dot
   ||com


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



[Bug libstdc++/33628] unary_function and pointer_to_unary_function issues with void template arguments

2007-10-02 Thread pcarlini at suse dot de


--- Comment #1 from pcarlini at suse dot de  2007-10-02 17:43 ---
Well, the implementation of std::unary_function is 100% spelled out in the
(current) standard. Almost the same for pointer_to_unary_function. As far as I
can see, if we have an issue is not in our specific implementation...


-- 


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