https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62198

--- Comment #4 from Gary Funck <gary at intrepid dot com> ---
I realize that this bug has been closed as invalid, thus making the warning
valid.  

However, if the warning is valid what can be done to this declaration to avoid
the warning?

const int (*X0)[10] = alloc (10 * sizeof (int));

The C99 spec. says:

6.7.3 Semantics

8. If the specification of an array type includes any type qualifiers,
the element type is so qualified, not the array type. If the
specification of a function type includes any type qualifiers,
the behavior is undefined.116)

116) Both of these can occur through the use of typedefs

Since the constraint above talks about the qualifiers being propagated to the
element type, is it possible at all for an array type to be qualified?  what is
the syntax for that?

It seems reasonable to conclude for the purpose of determining compatibility in
the case of assignment of a qualified pointer-to-void to a pointer-to-array
with a qualified element type that the ultimate element type would be used, but
I didn't find anywhere in the C99 spec. that this was explicitly discussed.

It's interesting that g++ just banned this situation outright:

error: invalid conversion from ‘const void*’ to ‘const int (*)[10]’
[-fpermissive]

Reply via email to