public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/86259] [8 Regression] min(4, strlen(s)) optimized to strlen(s) with -flto
       [not found] <bug-86259-4@http.gcc.gnu.org/bugzilla/>
@ 2021-05-04 10:57 ` rguenth at gcc dot gnu.org
  2021-05-04 17:25 ` msebor at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-05-04 10:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #39 from Richard Biener <rguenth at gcc dot gnu.org> ---
Martin - this is another one, is there sth simple safe that can be done on the
8 branch?

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

* [Bug tree-optimization/86259] [8 Regression] min(4, strlen(s)) optimized to strlen(s) with -flto
       [not found] <bug-86259-4@http.gcc.gnu.org/bugzilla/>
  2021-05-04 10:57 ` [Bug tree-optimization/86259] [8 Regression] min(4, strlen(s)) optimized to strlen(s) with -flto rguenth at gcc dot gnu.org
@ 2021-05-04 17:25 ` msebor at gcc dot gnu.org
  2021-05-14 10:49 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-05-04 17:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #40 from Martin Sebor <msebor at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #39)
> Martin - this is another one, is there sth simple safe that can be done on
> the 8 branch?

The patch series that resolved this while also avoiding the otherwise
considerable test suite fallout was very large and intrusive.  The series was
further split up and ultimately committed by Jeff in r267482, r267483, r267498,
r267503, r267505, r267520, and r267537.  I don't think it's suitable for
backporting.

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

* [Bug tree-optimization/86259] [8 Regression] min(4, strlen(s)) optimized to strlen(s) with -flto
       [not found] <bug-86259-4@http.gcc.gnu.org/bugzilla/>
  2021-05-04 10:57 ` [Bug tree-optimization/86259] [8 Regression] min(4, strlen(s)) optimized to strlen(s) with -flto rguenth at gcc dot gnu.org
  2021-05-04 17:25 ` msebor at gcc dot gnu.org
@ 2021-05-14 10:49 ` jakub at gcc dot gnu.org
  2023-05-22 13:08 ` alx at kernel dot org
  2023-05-22 13:51 ` alx at kernel dot org
  4 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-05-14 10:49 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
   Target Milestone|8.5                         |9.0
         Resolution|---                         |FIXED
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #41 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The GCC 8 branch is being closed, fixed in GCC 9.1.

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

* [Bug tree-optimization/86259] [8 Regression] min(4, strlen(s)) optimized to strlen(s) with -flto
       [not found] <bug-86259-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2021-05-14 10:49 ` jakub at gcc dot gnu.org
@ 2023-05-22 13:08 ` alx at kernel dot org
  2023-05-22 13:51 ` alx at kernel dot org
  4 siblings, 0 replies; 5+ messages in thread
From: alx at kernel dot org @ 2023-05-22 13:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #42 from Alejandro Colomar <alx at kernel dot org> ---
I'm very confused by this ticket.

The discussion seems to be settled by Martin Sebor that the presented
code has UB due to pointer provenance issues, according to the WG14
interpretation of the standard.

GCC historically had relaxed rules on mem*() functions, to let old code
work as expected.  This is by no means required by ISO C, and is only
a GNU extension.  ISO C is stricter and under its rules, memcpy(3)
cannot cross subobject boundaries.  This is the ideal behavior, and the
intention is to tighten the rules so that code analysis becomes easier.

Nobody seemed to rebute Martin's analysys that it's UB with solid
ground, and I agree that it looks like UB.

Did I understand that correctly?

And then I see that something has been 'fixed' in GCC, and that the
ticket is marked as RESOLVED FIXED.  This is very confusing, since
nothing in the ticket really documents what was broken.  It seems that
GCC's relaxed rules on mem*() functions were extended to cover str*()
functions too.

May I ask why?  And may I ask a -fprovenance to get strict provenance
rules?  I find very confusing when code breaks provenance rules, because
simlarly to how a compiler will have trouble analyzing the code, a human
brain will have trouble understanding where some copy data came from (at
least that's true for mine).

See the following question, which seems to be very related to pointer
provenance rules: <https://software.codidact.com/posts/288138>.

I'd like to be able to guarantee that in my code nobody messes with
pointers to get magic copies out of nowhere.

Thanks.

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

* [Bug tree-optimization/86259] [8 Regression] min(4, strlen(s)) optimized to strlen(s) with -flto
       [not found] <bug-86259-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2023-05-22 13:08 ` alx at kernel dot org
@ 2023-05-22 13:51 ` alx at kernel dot org
  4 siblings, 0 replies; 5+ messages in thread
From: alx at kernel dot org @ 2023-05-22 13:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #43 from Alejandro Colomar <alx at kernel dot org> ---
GCC's manual also doesn't seem to document any deviation from ISO C
rules regarding mem*() functions.  It would be good to document what is
the GCC interpretation of ISO C regarding those rules, and what GCC
considers extensions.  And it would also be interesting to note the
reason for such extensions being old code, and that the idea is getting
rid of them at some point, maybe as default, or maybe via some flags
such as -fprovenance.

If str*() functions got the same exception recently, it would also be
good to mention that.

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

end of thread, other threads:[~2023-05-22 13:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-86259-4@http.gcc.gnu.org/bugzilla/>
2021-05-04 10:57 ` [Bug tree-optimization/86259] [8 Regression] min(4, strlen(s)) optimized to strlen(s) with -flto rguenth at gcc dot gnu.org
2021-05-04 17:25 ` msebor at gcc dot gnu.org
2021-05-14 10:49 ` jakub at gcc dot gnu.org
2023-05-22 13:08 ` alx at kernel dot org
2023-05-22 13:51 ` alx at kernel dot 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).