This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/11614] New: Incorrect handling of pointers to arrays
- From: "uweigand at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Jul 2003 15:19:21 -0000
- Subject: [Bug c++/11614] New: Incorrect handling of pointers to arrays
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11614
Summary: Incorrect handling of pointers to arrays
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: uweigand at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
The following testcase fails to compile with the error:
error: cannot convert `int (*)[0]' to `int (*)[]' in assignment
which appears to indicate that the type of the member 'a'
of 'struct test' was incorrectly determined.
Using a semantically equivalent workaround with typedef
makes the program work. Both variants work when compiled
with the C frontend.
struct test
{
#ifndef WORKAROUND
int (*a)[];
#else
typedef int int_array[];
int_array *a;
#endif
};
void test(void)
{
struct test s;
int (*a)[];
a = s.a;
}
>From my preliminary analysis, the bug seems to be caused by this
snippet in grokdeclarator (cp/decl.c), which doesn't distinguish
between an array and a pointer to array:
> /* VC++ spells a zero-sized array with []. */
> if (size == NULL_TREE && decl_context == FIELD && ! staticp
> && ! RIDBIT_SETP (RID_TYPEDEF, specbits))
> size = integer_zero_node;
I'm not familiar enough with the C++ frontend to fix this, however.
Any suggestions?
(B.t.w. why is this non-standard VC++ compatibility feature enabled
even in strict standard mode?)