Package: tcc
Version: 0.9.23-4.kon.1
Severity: normal

gcc-4.0 4.0.3-3 compiles this program all right, but tcc fails:
sizeof.c:5: pointer expected

int
main (void)
{
  char x[1];
  return (sizeof (x) [0]) - 1;
}

tcc 0.9.23-4.kon.1 is 0.9.23-4 + the patch from bug 418360.

/* C99 6.5.3p1 */
unary-expression:
        postfix-expression
        ++ unary-expression
        -- unary-expression
        unary-operator cast-expression
        sizeof unary-expression
        sizeof (type-name)
/* C99 6.5.2p1 */
postfix-expression:
        primary-expression
        postfix-expression [ expression ]
        postfix-expression ( argument-expression-list_opt )
        postfix-expression . identifier
        postfix-expression -> identifier
        postfix-expression ++
        postfix-expression --
        ( type-name ) { initializer-list }
        ( type-name ) { initializer-list , }
/* C99 6.5.1p1 */
primary-expression:
        identifier
        constant
        string-literal
        ( expression )

"sizeof (x)" can be a unary-expression but cannot be a
postfix-expression, and therefore it cannot be the left side in
the "postfix-expression [ expression ]" syntax.  So TCC is wrong.

"(x)[0]" can be a postfix-expression and thus a unary-expression,
making it a suitable argument for sizeof.  So GCC is right.

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 
'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/dash
Kernel: Linux 2.6.12-1-k7
Locale: LANG=fi_FI.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

Versions of packages tcc depends on:
ii  libc6                         2.3.6-7    GNU C Library: Shared libraries

Versions of packages tcc recommends:
ii  libc6-dev [libc-dev]          2.3.6-7    GNU C Library: Development Librari

-- no debconf information

Attachment: pgpHWcaP6fTsS.pgp
Description: PGP signature

Reply via email to