http://llvm.org/bugs/show_bug.cgi?id=16340

            Bug ID: 16340
           Summary: _Generic  selection  fails to select a compatible type
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

Created attachment 10684
  --> http://llvm.org/bugs/attachment.cgi?id=10684&action=edit
test case

_Generic selector fails to select any compatible type when a conversion from
array to pointer is needed although the standard clearly states:

$6.5.1.1 Generic selection

The controlling expression of a generic selection is not evaluated. If a
generic selection has a generic association with a type name that is compatible
with the type of the controlling expression, then the result expression of the
generic selection is the expression in that generic association. Otherwise, the
result expression of the generic selection is the expression in the default
generic association. None of the expressions from any other generic association
of the generic selection is evaluated.


In the case of:

_Generic("test", char *: 123)

The type of the controlling expression "test" is char[5], which is clearly
compatible with the type-name char* in the generic selection which should
return the int value 123.

Currently clang reports:

test.c:5:29: error: controlling expression type 'char [5]' not compatible with
any generic association type
    printf("%d\n", _Generic("test", char *: 123));
                            ^~~~~~

Which is wrong.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to