Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: John Nagle Newsgroups: comp.std.c Subject: Second draft, "Safe arrays and pointers for C" Date: Thu, 30 Aug 2012 12:48:15 -0700 Organization: A noiseless patient Spider Lines: 49 Message-ID: <503FC37F.8050701@animats.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Injection-Info: mx04.eternal-september.org; posting-host="be1bb0721696fa49da97c8fb91891936"; logging-data="23813"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/rH0AhMozl9jPoXeW+5+1W" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 Cancel-Lock: sha1:8HPqoIKCJpgCLHBEKpAEQSNAMbg= Xref: csiph.com comp.std.c:1626 In response to all the comments above under "Initial draft proposal: "Safe arrays and pointers for C", I have a new revision for discussion. http://www.animats.com/papers/languages/safearraysforc41.pdf Major changes: - It's made clearer that non-strict code can call strict code and vice versa, and that function prototypes can be written in strict style and called from both strict code (with checking) and non-strict code (without checking). Thus, there's a clear migration path to strict code - start with the low level libraries and work up. - The proposed generic functions have been removed. Instead, it is proposed to import the "decltype" feature from C++. This allows writing the generic functions needed for making "malloc" allocation type-safe as C macros. - The proposal is written relative to N1570. - Run time subscript and size checking action is as specified in N1570, Annex K. - The relationship with C variable length arrays is discussed. - The problem of forward-referenced formal parameters (where the declaration of an array is followed by a parameter with its size) is addressed, using the GCC forward declaration extension. - The restrictions on array length expressions needed for consistency between call and definition are made explicit. - Implications for this feature in C++ are briefly discussed, the intent being to avoid divergence from C++. The issue of how C++ style "name mangling" and variable length array parameters could coexist is addressed. This proposal is now potentially compatible with C++ as well as C. Please comment, as before. I would particularly like to hear from people involved with GCC as to how difficult a job it would be to implement this in GCC as an extension. Then we could get some experience with this approach. John Nagle