Why is there a sequence point immediately before library functions?

Viewed 105

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 actual call and after return statement (due to semicolon if there is another reason please let me know) but i couldn't understand the sentence above. Could anyone please explain this ?

1 Answers

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++).

Related