array of unknown bound handling

Steven L. Zook SLZook@Qualstar.com
Sat Jan 22 01:56:00 GMT 2005


Using the C++ test case:

struct sTed { sTed( unsigned N ) : pInts( ( int (*)[] )new int[ N ] ) {}
              int ( * pInts )[];
            };
struct sSam { sSam( unsigned N ) : pInts( ( int (*)[ 0 ] )new int[ N ] )
{}
              int ( * pInts )[];
            };


m68k-elf-gcc 3.3.5, produces:

testpp.cpp: In constructor `sTed::sTed(unsigned int)':
testpp.cpp:1: error: cannot convert `int (*)[]' to `int (*)[0]' in
initialization


m68k-elf-gcc 3.4.3, produces:

testpp.cpp: In constructor `sSam::sSam(unsigned int)':
testpp.cpp:4: error: cannot convert `int (*)[0u]' to `int (*)[]' in
initialization


I looked through bugzilla and the 3.4.3 Changelog(s) but couldn't find
anything relating to the changes in behavior. I seems to me that 8.3.4/1
in the C++ spec implies 3.4.3 has the correct behavior in this case.

BTW, 8.3.4/1 also says "If the constant-expression (5.19) is present, it
shall be an integral constant expression and its value shall be greater
than zero.", which says to me that what I did in sSam (which was done to
fix the sTed case under 3.3.x) is invalid. Should the compiler be
accepting it (perhaps it is a GCC extension)?

Should I submit a PR against 3.3.x, 3.4.x, both, or just leave quietly?



More information about the Gcc mailing list