Problem :
The __thread with template class static variable is not supported in Intel C++ compiler 11.0 and the compiler emits error. The issue is resolved in latest Intel C++ compiler 11.1.
$ cat tstcase.h
// tstcase.h
template <long F>
class keywordtest
{
public:
static __thread int z;
static __thread float pi;
public:
keywordtest()
{};
};
template <long F>
__thread int keywordtest<F>::z = -1;
template <long F>
__thread float keywordtest<F>::pi = 3.141;
$ cat tstcase.cpp
$ cat tstcase.cpp
#include <stdio.h>
#include "tstcase.h"
keywordtest<314> object;
int main()
{
printf ("static object.pi = %f\n", object.pi);
return 0;
}
$ g++ tstcase.cpp
$ gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20070626 (Red Hat 4.1.2-14)
$ icc tstcase.cpp
tstcase.h(14): error: template argument list must match the parameter list
__thread int keywordtest<F>::z = -1;
^
tstcase.h(16): error: template argument list must match the parameter list
__thread float keywordtest<F>::pi = 3.141;
^
compilation aborted for tstcase.cpp (code 2)
$ icc -V
Intel® C Intel® 64 Compiler Professional for applications running on Intel® 64, Version 11.0 Build 20090609 Package ID: l_cproc_p_11.0.084
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.
Environment :
Linux, Intel C++ compiler 11.0
Resolution :
This issue is resolved in Intel C++ compiler 11.1.
$ icpc tstcase.cpp
$ ./a.out
static object.pi = 3.141000
$icc -V
Intel® C Intel® 64 Compiler Professional for applications running on Intel® 64, Version 11.1 Build 20100806 Package ID: l_cproc_p_11.1.073
Copyright (C) 1985-2010 Intel Corporation. All rights reserved.
The __thread with template class static variable is not supported in Intel C++ compiler 11.0 and the compiler emits error. The issue is resolved in latest Intel C++ compiler 11.1.
$ cat tstcase.h
// tstcase.h
template <long F>
class keywordtest
{
public:
static __thread int z;
static __thread float pi;
public:
keywordtest()
{};
};
template <long F>
__thread int keywordtest<F>::z = -1;
template <long F>
__thread float keywordtest<F>::pi = 3.141;
$ cat tstcase.cpp
$ cat tstcase.cpp
#include <stdio.h>
#include "tstcase.h"
keywordtest<314> object;
int main()
{
printf ("static object.pi = %f\n", object.pi);
return 0;
}
$ g++ tstcase.cpp
$ gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20070626 (Red Hat 4.1.2-14)
$ icc tstcase.cpp
tstcase.h(14): error: template argument list must match the parameter list
__thread int keywordtest<F>::z = -1;
^
tstcase.h(16): error: template argument list must match the parameter list
__thread float keywordtest<F>::pi = 3.141;
^
compilation aborted for tstcase.cpp (code 2)
$ icc -V
Intel® C Intel® 64 Compiler Professional for applications running on Intel® 64, Version 11.0 Build 20090609 Package ID: l_cproc_p_11.0.084
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.
Environment :
Linux, Intel C++ compiler 11.0
Resolution :
This issue is resolved in Intel C++ compiler 11.1.
$ icpc tstcase.cpp
$ ./a.out
static object.pi = 3.141000
$icc -V
Intel® C Intel® 64 Compiler Professional for applications running on Intel® 64, Version 11.1 Build 20100806 Package ID: l_cproc_p_11.1.073
Copyright (C) 1985-2010 Intel Corporation. All rights reserved.
