> From: [email protected] On Behalf Of Jakob Bohm > Sent: Tuesday, 29 May, 2012 03:34
> On 5/27/2012 2:29 AM, Jeremy Farrell wrote: <snip: ANSI C and POSIX make free(NULL) no-op> > > Note that when considering portability, C99 is not yet > fully implemented everywhere, so when I say "ANSI C" > without qualification, I generally refer to C89 plus > the two TR update documents that mostly focused on > things many compilers were already doing. > That's confused. There were no Technical Reports (TR) for C89/90. There were two Technical Corrigenda *TC* AND one Normative Amendment (NA or AMD) which substantially expanded the 'wchar_t' (effectively Unicode) features. The 2 TCs and NA for C90 were rolled-up into C99, and similarly the three TCs for C99 are rolled-up into C11 (which I don't think is fully implemented *any*where). (I think the committee starting draft for C11, n1256, has already been pointed to; that's exactly C11+TC[123].) There were several TRs for C99; two were apparently accepted for roll-up to C11, but I didn't track them. > Having no current access to the C89 standard or its > drafts, I am relying on the experience that many "C89" > real world systems I have encountered did not tolerate > free(NULL). In contrast all recent C++ specifications > (starting with The C++ Programming Language 2nd Ed. > which preceded all published standards), insist that > delete (char*)NULL must be a safe NOP. > C89/90 is hard to find now, but it definitely did specify free(NULL) is no-op. You say elsethread you may have confused C89 free() with generally similar calls in OS or perhaps libraries; those certainly might not be safe for NULL. I'll believe Stroustrup emphasized it more clearly, though my TC++PL was 'borrowed' years ago and never recovered. (K&R1 and then 2 were pretty exact but often quite terse. TC++PLs were also exact but often more explanatory.) > As C99 adopted many other features from C++ (such as > declarations between statements), the free(NULL) > behavior might also be new in C99. > The only three 'backports' I know are mixed-declarations, prototypes, and // comments. Those are important features, but not many. Well, and C99 tgmath (and now C11 _Generic) is vaguely similar to C++ templates, but only vaguely. ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [email protected] Automated List Manager [email protected]
