[cfe-dev] [patch] _Generic constant string used as controlling expression

Prathamesh Kulkarni bilbotheelffriend at gmail.com
Mon Apr 28 10:58:21 PDT 2014


Hi,
   I had reported this bug earlier:
http://clang-developers.42468.n3.nabble.com/Generic-constant-string-as-controlling-expression-td4036519.html

For following case:
int main(void)
{
  int x = _Generic("hello", char *: 1);
}

clang gives error:
generic_expr.c:3:20: error: controlling expression type 'char [6]' not
compatible with any generic association type
 int x = _Generic ("hello", char *: 1);

I guess that's because array-to-pointer conversion is not performed
when array is used as controlling expression.
gcc-4.9 compiles the above test-case.

I have attached a patch that performs array-to-pointer conversion
when array is used as controlling expression, and it compiles the
above test-case.
OK to commit ?

Thanks and Regards,
Prathamesh
-------------- next part --------------
A non-text attachment was scrubbed...
Name: genericexpr.patch
Type: text/x-patch
Size: 663 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140428/fddaefd0/attachment.bin>


More information about the cfe-dev mailing list