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

            Bug ID: 116443
           Summary: String values not accepted for case labels
           Product: gcc
           Version: 14.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rasmus.tempcache at gmail dot com
  Target Milestone: ---

String character values do not seem to be able to be evaluated in switch cases.
This gives the error "case label does not reduce to an integer constant".

Here's an example that works in clang but not in GCC:

static int function(int var)
{
  switch (var)
  {
  case "str a"[0] + "str b"[2]:
    return 0;

  default:
    return 1;
  }
}

I'm currently using 14.1.0 and have been following for the changelogs for newer
releases but haven't noticed this mentioned in any of them.

Reply via email to