Bug 39582 - bad errors for some uses of [*] arrays
Summary: bad errors for some uses of [*] arrays
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: 4.5.0
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks: 16989
  Show dependency treegraph
 
Reported: 2009-03-29 20:09 UTC by Joseph S. Myers
Modified: 2009-04-25 21:21 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.5.0
Known to fail:
Last reconfirmed: 2009-03-30 01:10:31


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph S. Myers 2009-03-29 20:09:32 UTC
With -std=c99 -pedantic-errors, the code

void foo11d(int x[sizeof(int *[*])]);

receives the diagnostics:

t.c:1: warning: '[*]' not in a declaration
t.c:1: error: ISO C forbids zero-size array 'x'

There certainly isn't a zero-size array (a GNU extension) here; there's
a use of [*] arrays that ended up being valid with the final resolution
of DR#341 (see <http://gcc.gnu.org/ml/gcc-patches/2009-02/msg00133.html>)
and the result of sizeof should be variable, not a constant 0, in this
case.
Comment 1 Joseph S. Myers 2009-04-25 21:19:23 UTC
Subject: Bug 39582

Author: jsm28
Date: Sat Apr 25 21:19:09 2009
New Revision: 146787

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=146787
Log:
	PR c/39582
	* c-typeck.c (c_expr_sizeof_type): Create a C_MAYBE_CONST_EXPR
	with non-null C_MAYBE_CONST_EXPR_PRE if size of a variable-length
	type is an integer constant.

testsuite:
	* gcc.dg/vla-20.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/vla-20.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-typeck.c
    trunk/gcc/testsuite/ChangeLog

Comment 2 Joseph S. Myers 2009-04-25 21:21:04 UTC
Fixed for 4.5.