Compiler internal error: segmentation error in gcc. when sending a variation template to the structure

I am trying to compile the following code:

#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

I am using gcc 4.8.1 and I get the following error:

internal compiler error: Segmentation fault
 struct Container
        ^

Why doesn't gcc compile it? Is this code correct?

+4
source share
1 answer

Compiling with Clang shows an error:

main.cpp:4:8: error: declaration of 'Container' shadows template parameter
struct Container

if you rename the structure or template patternmeter, the code also compiles in g ++, I don’t know if the same name from them was random or intentional.


In addition, g ++ 4.8.2 and 4.9 work fine and give a similar error like Clang.

+6
source

Source: https://habr.com/ru/post/1543533/


All Articles