[cfe-dev] Using arrow operator with array generates incorrect diagnostic

Carl Lewis carl.g.lewis at gmail.com
Sun Dec 16 00:05:07 PST 2007


Code like this:

struct simple { int i; };

void f(void) {
    struct simple s[1];
    s->i = 1;
}

produces the error:

$ clang -fsyntax-only test.c
test.c:8:6: error: member reference is not a pointer
    s->i = 1;
     ^ ~
1 diagnostic generated.

My understanding is that this is legal as per C99 6.3.2.1 p3:

Except when it is the operand of the sizeof operator or the unary &
operator, or is a
string literal used to initialize an array, an expression that has
type ''array of type'' is
converted to an expression with type ''pointer to type'' that points
to the initial element of
the array object and is not an lvalue.

My attempt at a patch is attached.

Carl.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: array-with-arrow-operator.diff
Type: text/x-patch
Size: 629 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20071216/3ef37b06/attachment.bin>


More information about the cfe-dev mailing list