public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/26205]  New: pointer to member template parameter can't be null
@ 2006-02-10  1:08 jeffp at doomsday dot org
  2006-02-10  1:19 ` [Bug c++/26205] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: jeffp at doomsday dot org @ 2006-02-10  1:08 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 5+ messages in thread
[parent not found: <bug-26205-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2013-11-15 18:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-10  1:08 [Bug c++/26205] New: pointer to member template parameter can't be null jeffp at doomsday dot org
2006-02-10  1:19 ` [Bug c++/26205] " pinskia at gcc dot gnu dot org
2006-02-15 19:37 ` bangerth at dealii dot org
2006-02-15 19:55 ` jeffp at doomsday dot org
     [not found] <bug-26205-4@http.gcc.gnu.org/bugzilla/>
2013-11-15 18:05 ` paolo.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).