CC Compiler Instantiates Templates Too Eagerly
(Doc ID 2750304.1)
Last updated on DECEMBER 12, 2022
Applies to:
Oracle Solaris Studio - Version 12.4 to 12.6 [Release 12]Information in this document applies to any platform.
Symptoms
Given the following code:
template <class T>
struct Fail {
T data[5];
};
template <class RET_TYPE>
void trigger(const Fail<RET_TYPE( )>&) { }
template <class TYPE>
void call(const TYPE&) { }
int main( ) {
call(&trigger<int>);
}
struct Fail {
T data[5];
};
template <class RET_TYPE>
void trigger(const Fail<RET_TYPE( )>&) { }
template <class TYPE>
void call(const TYPE&) { }
int main( ) {
call(&trigger<int>);
}
Oracle Solaris Studio 12.3 compiles it without errors.
However, Oracle Solaris Studio 12.4 and Oracle Developer Studio 12.5 fail with:
"<SOURCE_FILE>", line 3: Error: Member functions may not be declared with template type parameters.
"<SOURCE_FILE>", line 17: Where: While specializing "Fail<int( )>".
"<SOURCE_FILE>", line 17: Where: Specialized in non-template code.
"<SOURCE_FILE>", line 3: Error: Cannot have an array of functions.
"<SOURCE_FILE>", line 17: Where: While specializing "Fail<int( )>".
"<SOURCE_FILE>", line 17: Where: Specialized in non-template code.
2 Error(s) detected.
"<SOURCE_FILE>", line 17: Where: While specializing "Fail<int( )>".
"<SOURCE_FILE>", line 17: Where: Specialized in non-template code.
"<SOURCE_FILE>", line 3: Error: Cannot have an array of functions.
"<SOURCE_FILE>", line 17: Where: While specializing "Fail<int( )>".
"<SOURCE_FILE>", line 17: Where: Specialized in non-template code.
2 Error(s) detected.
Oracle Developer Studio 12.6 fails only with
"<SOURCE_FILE>", line 3: Error: Cannot have an array of functions.
"<SOURCE_FILE>", line 17: Where: While specializing "Fail<int( )>".
"<SOURCE_FILE>", line 17: Where: Specialized in non-template code.
1 Error(s) detected.
"<SOURCE_FILE>", line 17: Where: While specializing "Fail<int( )>".
"<SOURCE_FILE>", line 17: Where: Specialized in non-template code.
1 Error(s) detected.
The example above compiles cleanly with every other compiler tried, including clang, g++ and several others.
Changes
Cause
To view full details, sign in with your My Oracle Support account. |
|
Don't have a My Oracle Support account? Click to get started! |
In this Document
Symptoms |
Changes |
Cause |
Solution |
References |