Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Bug related to initializer lists and initialization of static const members of a template class

Raffael_C_
Beginner
604 Views

Hi,

I think I found a bug in the Linux Version of the Intel c++ composer xe (version 14.0.2 20140120). Here is a small test case:

[cpp]

#include<vector>

#include<initializer_list>

template<class TYPE>

class ReferenceElement {

  static const std::vector<int> subEntityTypes_;

};

template<>

const std::vector<int> ReferenceElement<int>::subEntityTypes_{ 1 };

int main() {

  return 0;

}

[/cpp]

This code snippet compiles fine with Clang 3.4 and gcc 4.8.2, but if I try it with the Intel compiler on linux I get the following error message:

[cpp]

main.cpp(11): error: expected a ";"

const std::vector<int> ReferenceElement<int>::subEntityTypes_{ 1 };

[/cpp]

 

I hope this can be fixed eventually...

Raffael

0 Kudos
4 Replies
Hubert_H_Intel
Employee
604 Views

Raffael,

Initializer lists are working with 14.0 compilers using a g++ 4.6 or higher environment.

Regards, Hubert.

0 Kudos
Raffael_C_
Beginner
604 Views

Hi Hubert,

Thank you for the quick response. Do you know how I can find the version of my gcc environment, respectively what exactly do you mean with this? On my machine there is only gcc 4.8.2 installed so I believe the environment is also gcc 4.8.2.

Also I'd like to add that initializer_lists generally work with intel compiler but in this one particular case they don't. There are a few modifications you can make to the source to make it work:

- Remove the template argument from the template ReferenceElement

- Make the static const member a usual member and initialize it in a constructor.

Regards,

Raffael

0 Kudos
Sukruth_H_Intel
Employee
604 Views

Hi Raffael,

                   I was able to reproduce the issue that you are speaking about with both 14.0 and 15.0 version of the Intel(R) compiler. What Hubert meant to say maybe was that the above test case works fine with gcc/g++ 4.6 or higher. Yes, he is right. There is no issue with gcc/g++ for the above version when i tried with gcc-4.8.1.

shv@dpdknf01:~/quad$ icpc init_list1.cpp -std=c++11 
init_list1.cpp(15): error: expected a ";"
  const std::vector<int> ReferenceElement<int>::subEntityTypes_{ 1 };
                                                               ^

compilation aborted for init_list1.cpp (code 2)

shv@dpdknf01:~/quad$ g++ init_list1.cpp -std=c++11

shv@dpdknf01:~/quad$ ./a.out
ref element 1

shv@dpdknf01:~/quad$ g++ --version
g++ (GCC) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

shv@dpdknf01:~/quad$ icpc -V
Intel(R) C++ Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.4.208 Build 20140805
Copyright (C) 1985-2014 Intel Corporation.  All rights reserved.

Also gcc environment basically mean the compiler and other set of tools , put in simple way, its the binutils.

I would escalate this issue to our engineering team. Thanks for let us know about this issue.

Regards,

Sukruth H V

0 Kudos
Raffael_C_
Beginner
604 Views

Dear Sukruth,

Thanks a lot for taking the time, I really appreciate it and I hope that I was able to improve the quality of the intel compiler by a tiny bit :)

Raffael

0 Kudos
Reply