Given the following code example
struct S;
template<typename>
class C
{
public:
void f(bool b)
{
if (b)
g();
}
void g()
{
S{};
}
};
int main()
{
C<int>{}.f(false);
}
GCC correctly reports the following:
example.cpp: In instantiation of 'void C< <template-parameter-1-1> >::g() [with <template-parameter-1-1> = int]':
10 : required from 'void C< <template-parameter-1-1> >::f(bool) [with <template-parameter-1-1> = int]'
21 : required from here
15 : error: invalid use of incomplete type 'struct S'
Now my question is: Is this a guaranteed behavior that has some kind of rule in a standard or any other document?
To clarify my question:
C - , f() g() . f() main(). g() ( ), . g() if- f(). . , / , , g() ( ). ( ).
, , , , - (, ), -.
.