public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug web/61054] New: Clearly note effect of memcpy optimization improvements in 4.9 changes
@ 2014-05-04 12:57 harald at gigawatt dot nl
  2014-05-04 13:52 ` [Bug web/61054] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: harald at gigawatt dot nl @ 2014-05-04 12:57 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61054

            Bug ID: 61054
           Summary: Clearly note effect of memcpy optimization
                    improvements in 4.9 changes
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: web
          Assignee: unassigned at gcc dot gnu.org
          Reporter: harald at gigawatt dot nl

Consider this reduced program:

void *volatile null;
volatile long zerolen;

int main() {
  void *dst = null, *src = null;
  __builtin_memcpy (dst, src, zerolen);
  if (dst) __builtin_abort ();
}

This program is invalid, but until 4.8 it would compile and run without an
issue. As of 4.9, it aborts.

I'm not asking for GCC to change (the programs should be fixed instead), but it
is not clear from the GCC 4.9 Changes page that such code no longer works. This
affects real code using custom allocators and realloc-like functions, where
some of those realloc-like functions don't bother to check for null pointers
and assume zero-length memcpy is a no-op. When the old memory is then freed,
and their free-like function performs a null pointer check, that check is
optimised away if the function gets inlined.

Could the GCC 4.9 Changes page get a mention of this?

I do see "Better inlining of memcpy and memset that is aware of value ranges
and produces shorter alignment prologues." in the IA-32/x86-64 section, but I
cannot tell if it is related to that, or if it is actually arch-independent.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-05-04 15:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-04 12:57 [Bug web/61054] New: Clearly note effect of memcpy optimization improvements in 4.9 changes harald at gigawatt dot nl
2014-05-04 13:52 ` [Bug web/61054] " redi at gcc dot gnu.org
2014-05-04 14:06 ` harald at gigawatt dot nl
2014-05-04 15:54 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).