[Bug c++/26205] New: pointer to member template parameter can't be null

2006-02-09 Thread jeffp at doomsday dot org
struct Simple
{
int a;
};

template  struct Test
{
void Foo(T *obj, int v)
{
if (U != 0)
obj->*U = v;
}
};

int main(int argc, const char **argv)
{
Test t1;// ok
Test t2; // error, but should not be (works in MSVC
7/8)

Simple s;
t1.Foo(&s, 5);
}


Note: it also won't let you specify a default parameter of 0 for the template
parameter:

template  struct Test   // won't do this either

MSVC 7/8 handle the first case, but also can't handle the default parameter
(they crash with an internal compiler error).  MSVC 7/8 also won't handle
specialization of the Foo function for the 0 case, though the resultant code
generated is the same since the branch is optimized out.  I only mention this
to give you some other nuances to check for once the base bug is fixed.


-- 
   Summary: pointer to member template parameter can't be null
   Product: gcc
   Version: 3.4.4
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
    ReportedBy: jeffp at doomsday dot org


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



[Bug c++/26205] pointer to member template parameter can't be null

2006-02-15 Thread jeffp at doomsday dot org


--- Comment #3 from jeffp at doomsday dot org  2006-02-15 19:55 ---
The casting work-around doesn't compile under GCC.  It requires that the
template parameter be a constant-expression (which is true), which results in
the following error:

error: a casts to a type other than an integral or enumeration type cannot
appear in a constant-expression

I have yet to be able to figure out a work-around.  MSVC allows the cast, but
works with or without it.


-- 


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