[LLVMbugs] [Bug 16340] New: _Generic selection fails to select a compatible type

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Jun 15 21:21:32 PDT 2013


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: unassignedclangbugs at nondot.org
          Reporter: johnhuela at yahoo.com
                CC: llvmbugs at cs.uiuc.edu
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130616/a0dc3370/attachment.html>


More information about the llvm-bugs mailing list