Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c    |    Meh, in C you gotta define EVERYTHING    |    243,242 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 241,766 of 243,242    |
|    James Kuyper to Tristan Wibberley    |
|    Re: Semantic properties of finite string    |
|    02 Nov 25 20:49:51    |
      XPost: comp.theory       From: jameskuyper@alumni.caltech.edu              On 2025-11-01 16:36, Tristan Wibberley wrote:       > On 01/11/2025 02:32, Richard Damon wrote:       >> On 10/31/25 3:57 PM, Tristan Wibberley wrote:       >>> On 31/10/2025 18:06, Richard Damon wrote:       >>>> [H and H1] fail to be correct C       >>>> interpreters, as the code has a required diagnostic.       >>>       >>> Really? even in K&R C?       >>       >> Yep, the link step will fail as H and H1 are not defined.       >       > Is "link step" defined in K&R C?              Not in the first edition. Section 11.2 mentions that a program can be       made up of many files, and that declarations with external linkage can       refer to something defined in a different file, but that's about all       they say about it.              When the language was standardized, a lot more thought was put into it.       In C89, Section 2.1.1.2 describes the phases of translation of a       program, and phase 8 is described the link step (though it does not name       it as such): "All external object and function references are resolved.       Library components are linked to satisfy external references to       functions and objects not defined in the current translation. All such       translator output is collected into a program image which contains       information needed for execution in its execution environment."              In the second edition, K&R was brought into line with the latest draft       version of what would become C89. As a result, A.12 contains the       following simplified version of that specification: "The result is       translated, then linked together with other programs and libraries, by       collecting the necessary programs and data, and connecting external       functions and object references to their definitions."                     > The compiler can provide definitions for H--which is the only symbol       > missing a definition in the situation statement, IIRC--/to satisfy the       > situation/.              C89 3.7 says "... If an identifier declared with external linkage is       used in an expression (other than as part of the operand of a sizeof       operator), somewhere in the entire program there shall be exactly one       external definition for the identifier; otherwise, there shall be no       more than one."              Violation of a "shall" that occurs outside of a constraints section       means that the behavior is undefined, which in turn means that the C       standard imposes no requirements on the behavior of such a program. No       diagnostic is required, nor is the translation required to fail, so       Richard is wrong on those points.       Because the behavior is undefined, anything is permitted, including       providing a definition of H when the program itself contains none - but       it most certainly isn't required to do so, and I doubt that any normal C       compiler would do so.              I try my best to avoid olcott messages. Does he specify that his       nonsense requires an implementation that takes advantage of undefined       behavior in that fashion?              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca