Reputation: 318
Standard says that:
There is a sequence point immediately before a library function returns. C17dr § 7.1.4 3.
I know that there is a sequence point before the actual call and after the return statement (due to the semicolon; if there is another reason, please let me know) but I couldn't understand the sentence above. Could anyone please explain this?
Upvotes: 4
Views: 154
Reputation: 234875
It means you can write code like t = sqrt(t)
. It would be really annoying if you couldn't.
And the behaviour of the above would be undefined if the C standard didn't guarantee that the functions had sequencing points in prior to their returning.
Note that C standard library functions might be hardcoded by the compiler - so this is an important consideration. It also adds extra protection for the user of a standard library implementation that might implement some functions as macros (which is permitted subject to a plethora of rules).
(Note that the rule has been carried over to C++).
Upvotes: 2