public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107622] New: Missing optimization of switch-statement
@ 2022-11-10 20:11 klaus.doldinger64 at googlemail dot com
  2022-11-10 20:20 ` [Bug c++/107622] " pinskia at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: klaus.doldinger64 at googlemail dot com @ 2022-11-10 20:11 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107622
           Summary: Missing optimization of switch-statement
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: klaus.doldinger64 at googlemail dot com
  Target Milestone: ---

In the following example the default-case could not be reached. Therefore
introducing std::unreachable() should be useless. But the compiler produces
slightly better code with std::unreachable() as it removes one (unneccessary)
comparison (tested for x86 and avr targets).

volatile uint8_t o;

enum class State : uint8_t {A, B, C};

void g(const State s) {
    switch(s) {
    case State::A:
        o = 10;
        break;
    case State::B:
        o = 11;
        break;
    case State::C:
        o = 12;
        break;
    default:
//        std::unreachable(); // __builtin_unreachable();
        break;
    }
}

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

end of thread, other threads:[~2023-04-17  6:50 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-10 20:11 [Bug c++/107622] New: Missing optimization of switch-statement klaus.doldinger64 at googlemail dot com
2022-11-10 20:20 ` [Bug c++/107622] " pinskia at gcc dot gnu.org
2022-11-10 21:31 ` pinskia at gcc dot gnu.org
2022-11-11  4:57 ` klaus.doldinger64 at googlemail dot com
2022-11-11  5:01 ` klaus.doldinger64 at googlemail dot com
2022-11-11  9:20 ` rguenth at gcc dot gnu.org
2022-11-11 10:16 ` klaus.doldinger64 at googlemail dot com
2022-11-11 15:07 ` glisse at gcc dot gnu.org
2022-11-21 10:32 ` marxin at gcc dot gnu.org
2022-12-02 14:17 ` marxin at gcc dot gnu.org
2022-12-02 14:45 ` jakub at gcc dot gnu.org
2023-04-16 21:55 ` klaus.doldinger64 at googlemail dot com
2023-04-17  6:50 ` klaus.doldinger64 at googlemail dot com

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).