Weird error with variadic parameter pack expansion in constructor

Weird error with variadic parameter pack expansion in constructor

Hi,

I try to compile the following code on windows, Intel Compiler XE 2014 Update 1:

#include<memory>
struct CompositeGrid {
    template<class... GRID_IMPL>
    CompositeGrid(std::shared_ptr<GRID_IMPL>... gridImpls)  {    
    }
};
int main() {
  CompositeGrid a(std::shared_ptr<int>(new int(5)));
}

However this fails with the following error message:

parameterPackExpansion.cpp(5): error: parameter pack "GRID_IMPL" was referenced
but not expanded CompositeGrid(std::shared_ptr<GRID_IMPL>... gridImpls)  {
 
parameterPackExpansion.cpp(5): error: pack expansion does not make use of any argument packs

	      CompositeGrid(std::shared_ptr<GRID_IMPL>... gridImpls)  {

 

I think this is a bug since it compiles sucessfully on gcc 4.8.2. and clang 3.4 (under linux). Weirdly enough the bug is resolved if the Constructor takes an additional, non-variadic first argument.

Cheers,

Raffael

3 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.

 

Hello Raffael,

I believe this is the same problem as described in this note:

http://software.intel.com/en-us/forums/topic/501502

Please see my reply there for a description of the bug and a suggested workaround.

Sorry for the trouble!

Judy

 

 

Hi Judy,

Thanks a lot, the problem that you mentioned is indeed very similar. I actually read that post before I posted mine because I was not sure that it is exactly the same. For me the difference is that in my case the constructor is a template in a usual class whereas in the case of Steffan it is a usual constructor in a class template (with variadic templates).

I just hope it will be fixed in one of the upcoming releases, util then I can emply the workaround:)

Raffael

Deixar um comentário

Faça login para adicionar um comentário. Não é membro? Inscreva-se hoje mesmo!