E
Evan
So I have two versions of a program (these are complete programs, not
excerpts):
Version 1:
template <class T >
void foo() {
return bar( T() );
}
Version 2:
template <class T >
void foo() {
return (bar)( T() );
}
The only difference between the two is that in the second version, I
have put parentheses around bar.
GCC versions 3.4 and 4.1 and Comeau's online front end accept version 1
but reject version 2
ICC (9.1 I think), MSVC 7.1, and Sun CC accept both versions
So have a few questions:
1. There is no definition of bar. Why does it even compile at all?
(This holds true if I replace "flush" with something like "f") I guess
it's because it doesn't try to resolve the call until foo is
instantiated. Is this right?
2. Why is there a difference between the versions on GCC and Comeau?
3. What does the standard say about this? I'm guessing by #2 that it's
undefined
Evan
excerpts):
Version 1:
template <class T >
void foo() {
return bar( T() );
}
Version 2:
template <class T >
void foo() {
return (bar)( T() );
}
The only difference between the two is that in the second version, I
have put parentheses around bar.
GCC versions 3.4 and 4.1 and Comeau's online front end accept version 1
but reject version 2
ICC (9.1 I think), MSVC 7.1, and Sun CC accept both versions
So have a few questions:
1. There is no definition of bar. Why does it even compile at all?
(This holds true if I replace "flush" with something like "f") I guess
it's because it doesn't try to resolve the call until foo is
instantiated. Is this right?
2. Why is there a difference between the versions on GCC and Comeau?
3. What does the standard say about this? I'm guessing by #2 that it's
undefined
Evan