Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Raffael_C_
Beginner
131 Views

Possible bug with variadic templates and initializer list?

Hi,

If I try to compile

[cpp]

#include<initializer_list>

#include<iostream>

void foo(std::initializer_list<int> a) {

  for(auto b : a)

    std::cout << b << std::endl;

}

template<class... VALUES> 

void callFoo(VALUES... values) {

  foo({values...});

}

int main() {

  callFoo(1,2,3);

}

[/cpp]

Intel Composer XE 2014 (on Windows) says:

[cpp]

error: no instance of function template "foo" matches the argument list

            argument types are: (A<double, int>)

    foo<double, int>(A<double, int>());

[/cpp]

 

I believe this is a bug since it compiles without problems using gcc 4.8.2. and clang 3.4 on linux. Would it be possible to fix this in one of the upcoming releases?

Raffael

0 Kudos
2 Replies
Judith_W_Intel
Employee
131 Views

 

I can't reproduce this. It compiles fine when I tried it with our latest 14.0 development compiler.

Are you using MSVC++ 2013 (I assume you are or else it wouldn't find the initializer_list header file)?

Are you using 14.0 Update 1? Are you using any special switches?

If I try a compiler that was released around the same time as Update 1, I see this internal error. This was fixed in December 2013.

!%  //ssgfs001/cmplrarch/SWF/deploy_14_0/x86win/20131009_000000/build/win_debug/
bin/ia32/icl -c -w -Qstd=c++11 t2.cpp
Intel(R) C++ Compiler XE for applications running on IA-32, Version 14.0 Beta Bu
ild x
Built Oct  9 2013 05:33:54 by nbtester on SCXWQA85 in d:/users/nbtester/x86win_n
ightly/branch-14_0/20131009_000000/dev
Copyright (C) 1985-2013 Intel Corporation.  All rights reserved.

t2.cpp
t2.cpp(11): internal error: assertion failed: node_has_side_effects: bad node kind (shared/cfe/edgcpfe/il.c, line 20802)

    foo({values...});
    ^

compilation aborted for t2.cpp (code 4)

With our latest compiler it compiles successfully:

!% cat t2.cpp
#include<initializer_list>
#include<iostream>

void foo(std::initializer_list<int> a) {
  for(auto b : a)
  std::cout << b << std::endl;
}

template<class... VALUES>
void callFoo(VALUES... values) {
  foo({values...});
}

int main() {
  callFoo(1,2,3);
  return 0;
}

!% icl -c t2.cpp
Intel(R) C++ Compiler XE for applications running on IA-32, Version 14.0 Beta Build x
Built Jan  6 2014 18:06:04 by jward4 on JWARD4-DESK in D:/workspaces/14_0cfe/dev

Copyright (C) 1985-2014 Intel Corporation.  All rights reserved.

t2.cpp
!%

14.0 Update 2 is due to be released any day now so I hope this is fixed when you try it out.

But I'm not sure since I can't reproduce the same error that you are seeing..

Judy

Raffael_C_
Beginner
131 Views

Hi Judy,

Thanks a lot for having a look at this issue. I guess I have been a bit lazy, so here is the full description of my setup:

I have Visual Studio 2013 installed and with it comes a version of the STL that has support for initializer_lists. The exact version of MSVC is:

[cpp]

Microsoft (R) C/C++ Optimizing Compiler Version 18.00.21005.1 for x64

[/cpp]

On the Intel side I have installed Intel Composer XE 2014 SP1 Update 1 (package 139) and I compile the c++ file as follows:

[cpp]

Intel(R) Parallel Studio XE 2013 SP1

Copyright (C) 1985-2013 Intel Corporation. All rights reserved.

Intel(R) Composer XE 2013 SP1 Update 1 (package 139)

 

icl variadicInitializerList.cpp /Qstd=c++11

[/cpp]

(The environment variables have been set by executing the x64 batch script of the intel compiler:

[cpp]

C:\Program Files (x86)\Intel\Composer XE 2013 SP1\bin\ipsxe-comp-vars.bat intel64 vs2013

[/cpp]

In my case this doesn't compile at all but may be it is really fixed in the next version, lets see...

Raffael

Reply