[Bug c/81677] New: Can't declare pointer to array of incomplete type in struct

2017-08-02 Thread chris.ol...@iti-global.com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81677

Bug ID: 81677
   Summary: Can't declare pointer to array of incomplete type in
struct
   Product: gcc
   Version: 4.4.7
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: chris.ol...@iti-global.com
  Target Milestone: ---

Created attachment 41898
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41898&action=edit
test.c is the original source file, test.i is the preprocessor output

The following declaration is considered erroneous on GCC 4.7.7 at the least:

struct s { struct s (*ps)[16] };

I don't see anything in the C90 standard that would forbid this and - although
Clang rejects it - MSC (Windows), XL C (AIX), Sun C (solaris) accepts this
declaration.

Attached is a source file that demonstrates the failure on GCC with this
command (and resulting error):

$ gcc -ansi test.c
test.c:4: error: array type has incomplete element type

$ gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-bootstrap --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-gnu-unique-object
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk
--disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib
--with-ppl --with-cloog --with-tune=generic --with-arch_32=i686
--build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)

$ uname -a
Linux name.domain 2.6.32-358.el6.x86_64 #1 SMP Tue Jan 29 11:47:41 EST 2013
x86_64 x86_64 x86_64 GNU/Linux

[Bug c/81677] Can't declare pointer to array of incomplete type in struct

2017-08-02 Thread chris.ol...@iti-global.com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81677

--- Comment #2 from chris.ol...@iti-global.com ---
This isn't an array of incomplete type, but a pointer-to-array of incomplete
type; not just any incomplete type, but struct that is guaranteed to be
complete when the outermost } is encountered. As I interpret C90, if a member
can point to its own struct, then a member should be able to point to an array
of its own struct.

[Bug c/81677] Can't declare pointer to array of incomplete type in struct

2017-08-02 Thread chris.ol...@iti-global.com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81677

--- Comment #4 from chris.ol...@iti-global.com ---
(In reply to jos...@codesourcery.com from comment #3)
> Because the type doesn't exist,

I don't know what you mean by a type that "doesn't exist". A declared but
undefined struct is incomplete but exists nevertheless.

> neither does a pointer to such a type, as pointer types can only be 
> derived from types that exist, not from types that don't exist.

Are you saying that pointers can't point to incomplete types? That's expressly
allowed by pointers. Especially in the case of a member pointing to its own
struct.

[Bug c/81677] Can't declare pointer to array of incomplete type in struct

2017-08-02 Thread chris.ol...@iti-global.com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81677

--- Comment #7 from chris.ol...@iti-global.com ---
I'm not arguing that arrays declarations should be allowed to derive from
incomplete types, nor all pointers-to-array of incomplete type be allowed; I'm
specifically arguing that a struct should be able to point to an array of
themselves. That's my interpretation and that was my expectation.