public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/113981] New: risc-v: non-void C++ function with no return statement has no ret
@ 2024-02-18 18:29 Simon.Richter at hogyros dot de
  2024-02-18 18:33 ` [Bug target/113981] " pinskia at gcc dot gnu.org
  2024-02-19  9:42 ` redi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: Simon.Richter at hogyros dot de @ 2024-02-18 18:29 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113981
           Summary: risc-v: non-void C++ function with no return statement
                    has no ret
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Simon.Richter at hogyros dot de
  Target Milestone: ---

On RISC-V with -O3, the C++ program

int f() {}

emits a completely empty function.

It correctly warns about the missing return statement, but also does not emit a
"ret" instruction.

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

* [Bug target/113981] risc-v: non-void C++ function with no return statement has no ret
  2024-02-18 18:29 [Bug target/113981] New: risc-v: non-void C++ function with no return statement has no ret Simon.Richter at hogyros dot de
@ 2024-02-18 18:33 ` pinskia at gcc dot gnu.org
  2024-02-19  9:42 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-18 18:33 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>but also does not emit a "ret" instruction.

Because it is undefined in C++ to return from a fuction without a value.

*** This bug has been marked as a duplicate of bug 86761 ***

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

* [Bug target/113981] risc-v: non-void C++ function with no return statement has no ret
  2024-02-18 18:29 [Bug target/113981] New: risc-v: non-void C++ function with no return statement has no ret Simon.Richter at hogyros dot de
  2024-02-18 18:33 ` [Bug target/113981] " pinskia at gcc dot gnu.org
@ 2024-02-19  9:42 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2024-02-19  9:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
With -O0 or -fsanitize-trap=return you get a trap. With -fsanitize=return you
get a UBsan error. With -O3 you asked the compiler to optimize the heck out of
a function with undefined behaviour, what do you expect?

Either that function is never called (in which case why would you want a wasted
ret instruction increasing the binary size?) or it's called and has undefined
behaviour, which is not going to end well with -O3.

Why would you not just fix it when you see the warning?

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

end of thread, other threads:[~2024-02-19  9:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-18 18:29 [Bug target/113981] New: risc-v: non-void C++ function with no return statement has no ret Simon.Richter at hogyros dot de
2024-02-18 18:33 ` [Bug target/113981] " pinskia at gcc dot gnu.org
2024-02-19  9:42 ` 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).