Doesn't sdcc has a number of conformance tests for various C standards? Does such a thing even exist?
Daniel "Let us change our traditional attitude to the construction of programs. Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do." (Donald Knuth) "Yes, technogeeks can be funny, even if only to each other." ( http://www.boogieonline.com/revolution/science/humor/)" "Man is driven to create; I know I really love to create things. And while I'm not good at painting, drawing, or music, I can write software." (Yukihiro Matsumoto, a.k.a. ``Matz'') Em seg., 8 de set. de 2025, 08:35, Philipp Klaus Krause <p...@spth.de> escreveu: > Am 06.09.25 um 21:44 schrieb Alan Cox: > > > > I would disagree with your interpretation re C90. It's possible to > > allocate zero bytes, it's just metadata tracking space that is allocated > > but it's not an impossible act. So I believe you are compliant with C90 > > anyway. They just made it more explicit. > > > > Classic Unix returned a pointer for zero sized allocations and realloc. > > Well, the C90 wording is somewhat unclear: > > #include <stdlib.h> > void *realloc(void *ptr, size-t size); > Description > The realloc function changes the size of the object pointed to by ptr to > the size specified by size. The contents of the object shall be > unchanged up to the lesser of the new and old sizes. If the new size is > larger, the value of the newly allocated portion of the object is > indeterminate. If ptr is a null pointer, the realloc function behaves > like the malloc function for the specified size. Otherwise, if ptr does > not match a pointer earlier returned by the calloc, malloc, or realloc > function, or if the space has been deallocated by a call to the free > or realloc function. the behavior is undefined. If the space cannot be > allocated, the object pointed to by ptr is unchanged. If size is zero > and ptr is not a null pointer, the object it points to is freed. > Returns > The realloc function returns either a null pointer or a pointer to the > possibly moved allocated space. > > My understanding was that this would require realloc(ptr, 0) to free and > return a null pointer. AFAIK, that was also the understanding glibc came > up with. > From the C99 rationale, this was apparently an obvious, but not > necessarily desired understanding: "C89 appeared to require a null > return value, and the Committee felt that this was too restrictive." > > I'll probably change the manual to state that C90 is unclear here, and > sdcc might or might not conform. > > Philipp > > > > _______________________________________________ > Sdcc-user mailing list > Sdcc-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/sdcc-user >
_______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user