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

Steve Naroff snaroff at apple.com
Sun Dec 16 13:43:47 PST 2007


Carl,

I just submitted another fix to this bug.

Let me know if you have any questions (and thanks for the report!),

snaroff

On Dec 16, 2007, at 12:05 AM, Carl Lewis wrote:

> 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.
> <array-with-arrow- 
> operator.diff>_______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list