Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-88683

gcc: static_assert causes compilation failure in not-taken if constexpr branch

Linking RHIVOS CVEs to...Migration: Automation ...SWIFT: POC ConversionSync from "Extern...XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Undefined Undefined
    • rhel-9.7
    • rhel-9.5.z
    • gcc
    • None
    • No
    • Low
    • rhel-pt-gcc
    • ssg_platform_tools
    • 1
    • False
    • False
    • Hide

      None

      Show
      None
    • No
    • Red Hat Enterprise Linux
    • None
    • None
    • None
    • Unspecified Release Note Type - Unknown
    • Unspecified
    • Unspecified
    • Unspecified
    • None

      GCC rejects this code with an error:

      template <bool flag>
      void
      f()
      {
        if constexpr (flag) {
        } else {
          static_assert(false);
        }
      }
      
      void
      g()
      {
        f<true>();
      }
      

      I believe compilation should succeed.

      Seen with gcc-c++-11.5.0-5.el9_5.x86_64.

              sst-pt-gcc-issues SST PT GCC Bot
              fw@deneb.enyo.de Florian Weimer (Inactive)
              SST PT GCC Bot SST PT GCC Bot
              Vaclav Kadlcik Vaclav Kadlcik
              Votes:
              0 Vote for this issue
              Watchers:
              10 Start watching this issue

                Created:
                Updated:
                Resolved: