Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Abstract Syntax Tree for C programs Date: Wed, 05 Jun 2019 12:12:19 -0700 Organization: None to speak of Lines: 35 Message-ID: References: <5dd4672f-a571-40bc-bb1a-c14f6c631eb7@googlegroups.com> <8d90e6a8-097d-4573-a88a-1f5f56dda26d@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: reader02.eternal-september.org; posting-host="2e5690e26a3a02612d58fbc15f6a6031"; logging-data="17894"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ggwT//gq3/ZV7SP9mTnE1" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:QG/OZb4zX9GzQm61pb28URXyCAA= sha1:nxafBFgI7Sr9rhT1KhjqyhxVQ2c= Xref: csiph.com comp.lang.c:144491 David Brown writes: > On 04/06/2019 23:41, Keith Thompson wrote: >> David Brown writes: >>> On 04/06/2019 12:24, Bart wrote: >> [...] >>>>  int main (void) { >>>>     fn(1,2,3,4); >>>>     fn("hello world"); >>>>  } >>>> >>>> There are no declarations of 'fn' visible; should this code pass or >>>> fail? Apparently gcc passes this unless I do: >>> >>> Sure, the code passes - because it has specific known behaviour, in an >>> older version of C. >> >> No, it has undefined behavior in every version of C that has the concept >> of undefined behavior. The function fn is presumably defined somewhere. >> That definition is consistent with at most one of those calls. It is >> not possible to write a definition of fn for which both calls have >> behavior that is defined by the standard. >> >> (Of course an implementation could define the behavior.) > > You are assuming that the implementation of "fn" is written in C. I am not. If the implementation of fn is not written in C, then its behavior is not defined by the C standard. That's undefined behavior. [...] -- Keith Thompson (The_Other_Keith) kst-u@mib.org Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */