public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/110839] New: Bogus -Wreturn-type for unreachable switch default case
@ 2023-07-28  7:36 rguenth at gcc dot gnu.org
  2023-07-28  7:39 ` [Bug middle-end/110839] " rguenth at gcc dot gnu.org
  2023-07-28  7:51 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-28  7:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110839
           Summary: Bogus -Wreturn-type for unreachable switch default
                    case
           Product: gcc
           Version: 13.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

unsigned char random_ui8(void);
int f16RandomQOutP3 (void);
int f16RandomQOutPInf (void);
int f16RandomQInfP3 (void);
int f16RandomQInfPInf (void);
int f16Random( void )
{   

    switch ( random_ui8() & 7 ) {
     case 0:
     case 1:
     case 2:
        return f16RandomQOutP3();
     case 3:
        return f16RandomQOutPInf();
     case 4:
     case 5:
     case 6:
        return f16RandomQInfP3();
     case 7:
        return f16RandomQInfPInf();
    }
}

diagnoses

gcc -S t.c -O2 -Wreturn-type
t.c: In function 'f16Random':
t.c:23:1: warning: control reaches end of non-void function [-Wreturn-type]
   23 | }
      | ^

this is because pass_warn_function_return runs after lowering before any
optimization is done and the gimplifier adds a default: case that
falls through to the function end.

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

* [Bug middle-end/110839] Bogus -Wreturn-type for unreachable switch default case
  2023-07-28  7:36 [Bug c/110839] New: Bogus -Wreturn-type for unreachable switch default case rguenth at gcc dot gnu.org
@ 2023-07-28  7:39 ` rguenth at gcc dot gnu.org
  2023-07-28  7:51 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-28  7:39 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-07-28
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Similar testcase (also a bit harder to fix I guess):

int f(unsigned x)
{
  switch ( x & 1 ) {
    case 0:
    case 1:
    return 1;
  }
}

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

* [Bug middle-end/110839] Bogus -Wreturn-type for unreachable switch default case
  2023-07-28  7:36 [Bug c/110839] New: Bogus -Wreturn-type for unreachable switch default case rguenth at gcc dot gnu.org
  2023-07-28  7:39 ` [Bug middle-end/110839] " rguenth at gcc dot gnu.org
@ 2023-07-28  7:51 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-28  7:51 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 95513.

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

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

end of thread, other threads:[~2023-07-28  7:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-28  7:36 [Bug c/110839] New: Bogus -Wreturn-type for unreachable switch default case rguenth at gcc dot gnu.org
2023-07-28  7:39 ` [Bug middle-end/110839] " rguenth at gcc dot gnu.org
2023-07-28  7:51 ` pinskia 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).