static inline template

I’ve been having a problem compiling octave and this is a simple example of what I’m running into. Is the following valid C++ and there’s a compiler error, or does it not conform to the standard? If the latter can you point to to a chapter/verse?

[chulbert@hulbert64 ~]$ pgCC -Minform=inform test2.cc
“test2.cc”, line 10: error: a storage class may not be specified here
static inline void a (int &x)
^

1 error detected in the compilation of “test2.cc”.
[chulbert@hulbert64 ~]$ g++ -Wall -pedantic test2.cc
[chulbert@hulbert64 ~]$ cat test2.cc
#include <stdlib.h>

template
static inline void a (T &x)
{
x=x+1;
}

template <>
static inline void a (int &x)
{
x=x+1;
}

int main(void)
{
int y = -1;
a(y);
return y;
}
[chulbert@hulbert64 ~]$

Hi Chris,

From one of our C++ engineers:

The test case below is nonstandard: paragraph 7.1.1/1 of the
standard says (among other things):

“A storage-class-specifier shall not be specified in
an explicit specialization […]”

However, we are considering it a GNU compatabilty issue and have entered a feature request (TPR#3968). Support for this feature should be available in a future release.

Thanks,
Mat

FYI, this feature has been added as of the PGI 2010 compilers.

  • Mat