On Mon, May 24, 2021 at 12:37:30AM +0200, Bernhard Reutner-Fischer wrote: > On 21 May 2021 22:56:09 CEST, Bill Schmidt via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > >>> + char *buf = (char *) malloc (lastpos - pos + 2); > >>> + memcpy (buf, &linebuf[pos], lastpos - pos + 1); > >>> + buf[lastpos - pos + 1] = '\0';
> You saw the unchecked usage of the malloc return value, did you? Yes, and it is Good. We do not assert on things that will fail on the next statement anyway, in general. Also, this is not part of the compiler, this is a tool used to *build* the compiler, so it is fine to have less user-friendly errors anyway. > We certainly warn about that, I'd hope. Maybe I just don't see what you mean? In general, it is good that we do *not* do superfluous checks normally. There is nothing useful we could say about an out-of-memory situation. If this was in GCC itself we would get a helpful ICE as-is. Since this is in a generator file we can assume whoever debugs this knows how to fire up GDB for it, so it is fine as well. There are thousands of ways a developer can crash the generators by giving bad inputs. An out-of-memory condition is not likely at all, compared to that. Segher