Bug 55408 - ICE for member template definition with non-type variadic parameter
Summary: ICE for member template definition with non-type variadic parameter
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid, ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2012-11-20 07:18 UTC by lucdanton
Modified: 2021-08-08 06:44 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-08-07 00:00:00


Attachments
Reproducible testcase (124 bytes, text/x-c++src)
2012-11-20 07:18 UTC, lucdanton
Details

Note You need to log in before you can comment on or make changes to this bug.
Description lucdanton 2012-11-20 07:18:04 UTC
Created attachment 28740 [details]
Reproducible testcase

$ g++-snapshot --version
g++-snapshot (Debian 20120915-1) 4.8.0 20120915 (experimental) [trunk revision 191353]

When attempting to compile this program:

struct foo {
    template<int*>
    void bar();
};

template<int*...>
void foo::bar() {}

int main()
{
    extern int i;
    foo {}.bar<&i>();
}

GCC complains:

main.cpp: In function 'int main()':
main.cpp:12:21: internal compiler error: Segmentation fault
     foo {}.bar<&i>();
                     ^

Some casual investigating suggests that this happens every time the definition for a member template is exactly the same as its declaration save for the fact that a non-type parameter is made variadic. Otherwise, e.g. if the parameter in question is a type or template parameter in the declaration or if the template is declared taking int and defined taking long... then GCC correctly reports that the definition doesn't have a match.
Comment 1 Marek Polacek 2012-11-20 08:18:57 UTC
Happens even with r188998.
Comment 2 Paolo Carlini 2016-05-23 09:06:14 UTC
Lately we wrongly accepts the code.
Comment 3 Andrew Pinski 2021-08-08 06:44:48 UTC
We reject this:
struct foo {
    template<int*>
    void bar();
};

template<int*, int>
void foo::bar() {}

But incorrectly accepts:
struct foo {
    template<int*>
    void bar();
};

template<int*...>
void foo::bar() {}