public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/84414] miscompile due to assuming that object returned by value cannot alias its own member pointer values
       [not found] <bug-84414-4@http.gcc.gnu.org/bugzilla/>
@ 2021-12-17  3:17 ` pinskia at gcc dot gnu.org
  2021-12-17  3:17 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-17  3:17 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.6.4, 4.8.5, 6.1.0

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

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

* [Bug c++/84414] miscompile due to assuming that object returned by value cannot alias its own member pointer values
       [not found] <bug-84414-4@http.gcc.gnu.org/bugzilla/>
  2021-12-17  3:17 ` [Bug c++/84414] miscompile due to assuming that object returned by value cannot alias its own member pointer values pinskia at gcc dot gnu.org
@ 2021-12-17  3:17 ` pinskia at gcc dot gnu.org
  2023-11-03  8:24 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-17  3:17 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-12-17

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
.

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

* [Bug c++/84414] miscompile due to assuming that object returned by value cannot alias its own member pointer values
       [not found] <bug-84414-4@http.gcc.gnu.org/bugzilla/>
  2021-12-17  3:17 ` [Bug c++/84414] miscompile due to assuming that object returned by value cannot alias its own member pointer values pinskia at gcc dot gnu.org
  2021-12-17  3:17 ` pinskia at gcc dot gnu.org
@ 2023-11-03  8:24 ` rguenth at gcc dot gnu.org
  2024-02-20 12:55 ` redi at gcc dot gnu.org
  2024-03-01 17:19 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-11-03  8:24 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org
   Last reconfirmed|2021-12-17 00:00:00         |2023-11-3

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Re-confirmed.

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

* [Bug c++/84414] miscompile due to assuming that object returned by value cannot alias its own member pointer values
       [not found] <bug-84414-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2023-11-03  8:24 ` rguenth at gcc dot gnu.org
@ 2024-02-20 12:55 ` redi at gcc dot gnu.org
  2024-03-01 17:19 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2024-02-20 12:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Richard Smith from comment #2)
> In fact, I think the *only* problem here is that the above rule does not
> allow the caller and the callee to observe the objects having the same
> address.

Would it be fair to argue that the A::children pointer storing the address of
the temporary becomes an invalid pointer value as soon as the temporary is
destroyed, and then it's not valid to use that invalid pointer value. Testing
`a.children == &a` has an unspecified (at best?) result, so you can't actually
detect whether a temporary was created or not. You can observe that the
arbitrary bit pattern of an invalid pointer value happens to equal &a but that
bit pattern could have magically morphed when it became invalid (because the
implementation tracks pointer provenance and intentionally messes with pointer
values when they become invalid just to screw with you).

Inside Bar using a.children[i] is using the invalid pointer value that points
to an out-of-scope temporary, which is UB. Attempting to observe whether
a.children == &a also uses that invalid pointer value and has an unspecified
result.

> I'll take this to the committee and see whether we can get that rule relaxed
> slightly.

I see you sent the email with subject "on implicit object copies in function
return and alias analysis" and nobody replied. I don't think it ever made it to
the issues list either.

I'll repeat the above argument there.

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

* [Bug c++/84414] miscompile due to assuming that object returned by value cannot alias its own member pointer values
       [not found] <bug-84414-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2024-02-20 12:55 ` redi at gcc dot gnu.org
@ 2024-03-01 17:19 ` redi at gcc dot gnu.org
  4 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2024-03-01 17:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is now https://cplusplus.github.io/CWG/issues/2868.html

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

end of thread, other threads:[~2024-03-01 17:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-84414-4@http.gcc.gnu.org/bugzilla/>
2021-12-17  3:17 ` [Bug c++/84414] miscompile due to assuming that object returned by value cannot alias its own member pointer values pinskia at gcc dot gnu.org
2021-12-17  3:17 ` pinskia at gcc dot gnu.org
2023-11-03  8:24 ` rguenth at gcc dot gnu.org
2024-02-20 12:55 ` redi at gcc dot gnu.org
2024-03-01 17:19 ` 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).