Studying the definition rule 1 on Wikipedia, I was stuck with the following example in the Examples section:
struct S;
...
S f();
...
I know that stack space should be allocated for the return value, but when I saw this example, I thought that C ++ calling conventions might indicate that the stack control for the return value is handled by a block of code in which this function not the block of code in which it is called. Therefore, I examined the “C and C ++ calling convention” (recall that the problem of allocating stack return values may be the main difference), and came across this answer , which indicates that the “calling convention” is not defined by the standard.
However, given the obvious requirement that the above code snippet is valid, it seems to me that there should be some restrictions when invoking an agreement to support the above code snippet.
I'm right? Is the C ++ standard an implicit requirement that stack control for the return value of a function be handled by code defining the function to support the syntax above?
source
share