[Bug c++/26205] New: pointer to member template parameter can't be null
jeffp at doomsday dot org
gcc-bugzilla@gcc.gnu.org
Fri Feb 10 01:08:00 GMT 2006
struct Simple
{
int a;
};
template <typename T, int T::*U> struct Test
{
void Foo(T *obj, int v)
{
if (U != 0)
obj->*U = v;
}
};
int main(int argc, const char **argv)
{
Test<Simple, &Simple::a> t1; // ok
Test<Simple, 0> 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 <typename T, int T::*U = 0> 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
More information about the Gcc-bugs
mailing list