Bug 35268 - ICE on virtual function in template with pointer-to-member-function template parameter
Summary: ICE on virtual function in template with pointer-to-member-function template ...
Status: RESOLVED DUPLICATE of bug 37093
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-20 20:07 UTC by Ben Johnson
Modified: 2008-12-29 06:53 UTC (History)
8 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

Note You need to log in before you can comment on or make changes to this bug.
Description Ben Johnson 2008-02-20 20:07:04 UTC
A template parameter is provided by a function call parameter (which should be rejected as it is non-constant).
The ICE does not occur (and an appropriate error is issued) if the code is rewritten so that func is an int or a pointer to a non-member function.


class Object
{
public:
    void something()
    {
    }
};

template<typename F, F func>
class Action
{
public:
    // Removing "virtual" prevents the error.
    virtual void run()
    {
        // Removing the next line prevents the error.
        (object->*func)();
    }

    Object *object;
};

template<typename F>
void *make_action(F func)
{
    // Replacing func with &Object::something prevents the error.
    return new Action<F, func>();
}

void bug()
{
    make_action(&Object::something);

    // Not using the templated function prevents the error:
    //new Action<typeof(&Object::something), &Object::something>();
}
Comment 1 Andrew Pinski 2008-12-29 06:53:36 UTC

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