Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: UB of memcpy(NULL, NULL, 0) Date: Mon, 24 Oct 2016 08:40:13 -0700 Organization: None to speak of Lines: 21 Message-ID: References: <7aec2d7f-6f2d-4621-9f98-91947f461f27@googlegroups.com> <18bf4226-5b9a-4603-9809-47cdd83cc16a@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="dc97ebc10d9ee65592f107439c98c97d"; logging-data="23225"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/fYKFk0fmEmantf6SW2wZ5" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:cRtRVtq8qXNMjq/O+29OBGnsBi0= sha1:k1Q6GBbffFGjhm0Be5FWjYg2mQ4= Xref: csiph.com comp.lang.c:95228 supercat@casperkitty.com writes: [...] > Note, btw, that if someone is actually interested in optimization, adding > a directive to indicate that a certain argument will be ignored in all > cases where some other argument is zero would allow a compiler to save > a load instruction when generating code like foo(somePtr, size) in cases > where it can determine [likely while in-lining the enclosing function] > that "size" will be zero. Easy optimization for a compiler to make, but > if memcpy doesn't offer such a guarantee no code which calls it will be > able to do so either except by adding a superfluous comparison. What would such a directive look like? You've proposed a lot of annotations to let programmers convey extra information to the compiler. I'd like to know just how much clutter your proposals would add to the language. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"