public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "david at westcontrol dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/56888] memcpy implementation optimized as a call to memcpy
Date: Mon, 18 Dec 2023 21:32:30 +0000	[thread overview]
Message-ID: <bug-56888-4-oWtcJ8TwUN@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-56888-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56888

--- Comment #47 from David Brown <david at westcontrol dot com> ---
(In reply to M Welinder from comment #46)
> Should "-std=c99" imply turning off these optimizations?
> 
> Creating calls to, say, strlen is incompatible with the C99 standard and
> perhaps better limited to "-std=gnu-something" or an opt-in f-flag.

How is it incompatible with C99 to create calls to library functions?  I can
think of a two possibilities:

1. If the function implementation plays with errno (allowed in 7.5p3), in a way
that is visible to the code.

2. If the function is called with parameters that may invoke undefined
behaviour (such as calling "strlen" without being sure that the parameter
points to a null-terminated string), where such undefined behaviour is not
already present.

If the user writes code that acts like a call to strlen (let's assume the
implementation knows strlen does not change errno), then the compiler can
replace it with a library call.  Similarly, if the user writes a call to
strlen, then the compiler can replace it with inline code.

As long as there is no difference in the observable behaviour, the
transformation is allowed.

Or am I missing something here?

  parent reply	other threads:[~2023-12-18 21:32 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-08 23:40 [Bug middle-end/56888] New: " xanclic at gmail dot com
2013-04-09  9:59 ` [Bug middle-end/56888] " mikpe at it dot uu.se
2013-04-09 10:01 ` rguenth at gcc dot gnu.org
2013-04-09 10:01 ` jakub at gcc dot gnu.org
2013-04-09 13:02 ` xanclic at gmail dot com
2013-04-09 13:17 ` rguenther at suse dot de
2013-04-09 13:20 ` xanclic at gmail dot com
2013-04-11 11:29 ` rguenth at gcc dot gnu.org
2013-06-23  0:01 ` jeff@deseret-tech.com
2013-07-17  7:52 ` paulo@matos-sorge.com
2013-07-17 17:10 ` brooks at gcc dot gnu.org
2013-07-17 17:28 ` xanclic at gmail dot com
2013-07-17 20:36 ` schwab@linux-m68k.org
2013-07-17 20:59 ` xanclic at gmail dot com
2013-07-17 22:31 ` schwab@linux-m68k.org
2013-07-18  0:26 ` xanclic at gmail dot com
2013-07-18 10:35 ` paulo@matos-sorge.com
2013-07-28  3:30 ` bugdal at aerifal dot cx
2013-10-02  7:59 ` bernd.edlinger at hotmail dot de
2013-10-02  8:17 ` rguenth at gcc dot gnu.org
2013-10-02  8:49 ` bernd.edlinger at hotmail dot de
2013-10-02  8:59 ` rguenther at suse dot de
2014-02-17  3:48 ` janosch.rux at web dot de
2014-04-29 13:50 ` rguenth at gcc dot gnu.org
2014-04-29 13:57 ` rguenth at gcc dot gnu.org
2014-04-29 14:47 ` bugdal at aerifal dot cx
2014-05-06 10:51 ` rguenth at gcc dot gnu.org
2014-05-06 10:52 ` rguenth at gcc dot gnu.org
2014-06-06 10:40 ` terra at gnome dot org
2014-06-06 11:54 ` rguenther at suse dot de
2014-11-03  7:09 ` fd935653 at opayq dot com
2020-08-16 22:51 ` pinskia at gcc dot gnu.org
2022-06-03  6:55 ` pinskia at gcc dot gnu.org
2022-10-26 17:06 ` pinskia at gcc dot gnu.org
2023-12-18 20:59 ` terra at gnome dot org
2023-12-18 21:32 ` david at westcontrol dot com [this message]
2023-12-19  2:07 ` terra at gnome dot org
2023-12-19  8:03 ` rguenth at gcc dot gnu.org
2023-12-19  8:06 ` rguenth at gcc dot gnu.org
2023-12-19  8:28 ` david at westcontrol dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-56888-4-oWtcJ8TwUN@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).