Bug 38681 - Internal compiler error. expr.c:6956 [Template instantiation with non-type value of member function ptr]
Summary: Internal compiler error. expr.c:6956 [Template instantiation with non-type va...
Status: RESOLVED DUPLICATE of bug 37093
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-31 07:40 UTC by Vamsidhar Juvvigunta
Modified: 2009-01-30 15:51 UTC (History)
9 users (show)

See Also:
Host: i486-linux-gnu
Target: i486-linux-gnu
Build: i486-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Preprocessed test case that causes the compiler error. (787 bytes, text/plain)
2008-12-31 07:42 UTC, Vamsidhar Juvvigunta
Details
Details of gcc from output of g++ -v -save-temps (1.01 KB, text/plain)
2008-12-31 07:43 UTC, Vamsidhar Juvvigunta
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vamsidhar Juvvigunta 2008-12-31 07:40:38 UTC
While trying to reinvent some suitablu smart technique for routing Gtk's static callbacks to object methods, I thought I had created a suitably brilliant solution. Gcc could not digest it. While I am looking at smarter solutions from boost or loki, I would like to see if I really was onto a workable solution.

I'm not sure if the triplet info above is useful enough. The bug posting guidelines promised eternal shame if I didn't do my very best. So ading more info, hopefully it is not all wasteful!

I have the as-packaged-for-ubuntu 8.10, g++-4.3.2 version.
Comment 1 Vamsidhar Juvvigunta 2008-12-31 07:42:49 UTC
Created attachment 17017 [details]
Preprocessed test case that causes the compiler error.
Comment 2 Vamsidhar Juvvigunta 2008-12-31 07:43:29 UTC
Created attachment 17018 [details]
Details of gcc from output of g++ -v -save-temps
Comment 3 Andrew Pinski 2008-12-31 07:49:50 UTC
>        ulong ConnectCB(GtkWidget* pWidget, const char* sigName, _R(_ClassType::*MemFun)(GtkWidget*, _A1))
 >       {
>            typedef CBFamily2<_ClassType, _R, GtkWidget*, _A1, MemFun> TCallbackType;


This code is invalid code, you are using a non constant expression for a template argument.
Comment 4 Andrew Pinski 2008-12-31 16:10:52 UTC
This is close to duplicate of bug 37093.
Comment 5 Vamsidhar Juvvigunta 2008-12-31 17:31:20 UTC
From the C++ standards doc (Latest download form the website) (excerpt listed below), I thought that member functions could be allowed. I am not entirely sure if *function* can also refer to *member-function*.

--------------------
4.  A non-type template-parameter shall have one of the following (optionally cv-qualified) types:
    — integral or enumeration type,
    — pointer to object or pointer to function,
    — reference to object or reference to function,
    — pointer to member., or
    — in a constrained template (14.10), a type archetype T for which the concept requirement std::NonTypeTemplateParamet
       is part of the template’s requirements.
--------------------

Did I understand this wrong ? Does the correct interpretation of the standard not allow for member-function-pointers as non-type arguments ?

The following links point to a different interpretation.

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=101628

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=196204

http://objectmix.com/c/382443-samples-non-type-template-argument-other-than-integral-types.html
Comment 6 Andrew Pinski 2008-12-31 17:40:43 UTC
>    — pointer to member., or

This includes pointer to member functions.
Comment 7 Wolfgang Bangerth 2009-01-30 15:51:43 UTC
(In reply to comment #5)
> Did I understand this wrong ? Does the correct interpretation of the standard
> not allow for member-function-pointers as non-type arguments ?

It does, but it requires them to be in a constant-expression context -- i.e.
informally speaking the compiler needs to know *at compile time* which member
function you refer to. You can use a function argument as a template
argument.

I think this is indeed a duplicate of PR 37093.

W.

W.

*** This bug has been marked as a duplicate of 37093 ***