[Bug c/90253] New: no warning for cv-qualified selectors in _Generic

amonakov at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Apr 25 17:25:00 GMT 2019


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

            Bug ID: 90253
           Summary: no warning for cv-qualified selectors in _Generic
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: amonakov at gcc dot gnu.org
  Target Milestone: ---

Controlling expression in _Generic undergoes lvalue conversion, so it will have
const/volatile qualifiers stripped. Therefore, a qualified selector cannot
possibly match, and it might make sense to warn when a user writes one.

In the following example the function returns 0, even though the user might
have expected to distinguish 'char' vs. 'const char':

int f(const char *c)
{
    return _Generic(*c, const char: 1, char: 0);
}


More information about the Gcc-bugs mailing list