Groups | Search | Server Info | Login | Register
| From | Tim Rentsch <tr.17687@z991.linuxsc.com> |
|---|---|
| Newsgroups | comp.std.c |
| Subject | Re: Function calls |
| Date | 2023-10-08 15:30 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <86wmvwbvc8.fsf@linuxsc.com> (permalink) |
| References | <calls-20231004163135@ram.dialup.fu-berlin.de> <86bkdddd20.fsf@linuxsc.com> <dff9aa5c-bb01-48e8-8793-79af97775a5dn@googlegroups.com> <865y3kc4et.fsf@linuxsc.com> <97fa4405-e88f-4984-a81b-af86c64dedc3n@googlegroups.com> |
James Kuyper <jameskuyper@alumni.caltech.edu> writes: > On Friday, October 6, 2023 at 8:38:10?AM UTC-4, Tim Rentsch wrote: > >> James Kuyper <james...@alumni.caltech.edu> writes: >> >>> On Wednesday, October 4, 2023 at 10:21:30?PM UTC-4, Tim Rentsch wrote: > > ... > >>>> AFAICT the C standard does not say explicitly that a function >>>> call gives or transfers control to the function being called. >>> >>> Section 6.9.1 is about function definitions,. while 6.5.2.2 is >>> about function calls, but 6.9.1 has several paragraphs of >>> specification about what happens when the function is called, and >>> the relevant one is: >>> >>> "After all parameters have been assigned, the compound statement >>> that constitutes the body of the function definition is executed." >>> (6.9.1p11). >> >> That is one relevant paragraph, but not the only relevant paragraph. >> Paragraph 10 of that section says >> >> On entry to the function, the size expressions of each variably >> modified parameter are evaluated and the value of each argument >> expression is converted to the type of the corresponding >> parameter as if by assignment. (Array expressions and function >> designators as arguments were converted to pointers before the >> call.) > > Yes, I mentioned that - "several paragraphs of specification about > what happens when the function is called". Specificaly, paragraphs 10, 11, and 12 give the semantics for when a function definition is elaborated. Note that the Standard does not say that these paragraphs are about what happens when the function is called, but what happens when the function is entered. It may be that the intention is to say what happens when the function is called, but the Standard doesn't say that. Paragraph 10 starts "On entry ..."; it does not say "On being called ...". >> What we are looking for is something that says the function is >> "entered", that is, that control is transferred. > > I find it confusing that you think something more needs to be > specified. I never said I think that. My guess is you didn't give full attention to the second paragraph of my first posting (and which you left out of your reply), which makes clear that I am asking questions of the OP, and not stating a position of my own. I don't have a dog in this fight. > The standard specifies that the compound statement that > constitutes the body of the function gets executed. No, it doesn't. What the Standard does say is that the function body (i.e., the compound statement that constitutes the body thereof) gets executed /if and when the function is entered/. No entry, no execution. The issue is Does the Standard say the function is entered (or called)? Apparently the Standard does not explicitly say that. Note that every other state-changing construct (or at least those I could think of: ++, --, assignment, if(), switch(), for(), do, while(), goto, break, continue, and most notably return) describe their semantics using a transitive verb (sometimes using the passive voice, but a transitive verb nonetheless). The semantic description of function call expressions does not use any such constructions for the action of calling the function (although there are several transitive verbs for actions that take place /before/ calling the function). Because the description of return says "A return statement terminates execution of the current function and returns control to its caller", it isn't surprising that some people expect to find some sort of similar wording about transferring control in the description of semantics for function call expressions (and in particular the OP did have such an expectation). But there isn't any. > Could you explain how that differs from having control transferred > to the function? Please give an example of what it would mean to > have the compound statement executed without transferring control. This question is moot because it starts from a false assumption. > To me, execution of the compound statement is what I want to have > happen. The question under discussion is about what the C standard says, not about what anyone wants or expects. Everyone, or at least every C programmer, expects and wants a function body to be executed when a function call expression is evaluated - there is no disagreement about that. > It may be a failure of my imagination, but I can't imagine what it > would mean for that to happen without transferring control, but if > it could, I also can't imagine caring. If you get to a point where a conversation doesn't make sense, you might want to go back and take another look at earlier comments, to see if there is a point where assumptions on the two sides diverged, either because someone didn't understand what the other party was saying or because what someone was trying to say wasn't said very well and may have been misinterpreted. If that has happened it's unlikely any progress will be made until the divergence has been identified and somehow reconciled.
Back to comp.std.c | Previous | Next — Previous in thread | Find similar
Re: Function calls Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-10-04 19:21 -0700
Re: Function calls James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-10-05 20:50 -0700
Re: Function calls Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-10-06 05:38 -0700
Re: Function calls James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-10-06 18:04 -0700
Re: Function calls Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-10-08 15:30 -0700
csiph-web