我正在尝试编译以下代码:
#include <iostream>
template<template <typename...> class Container,class... Args>
struct Container
{};
template<class T1,class T2>
struct Store
{};
int main()
{
Container<Store,int,double> a;
}
//g++ -Wall -std=c++11 main.cpp
ideone
我使用gcc 4.8.1,我得到以下错误:
internal compiler error: Segmentation fault
struct Container
^
为什么gcc不编译它?代码正确吗?
使用Clang编译显示错误:
main.cpp:4:8: error: declaration of 'Container' shadows template parameter
struct Container
如果重命名结构体或模板形参,代码也会在g++中编译,我不知道它们的名字相同是偶然的还是故意的。
同样,g++ 4.8.2和4.9工作得很好,并给出与Clang相似的错误。