------- Additional Comments From kmk at ssl dot org  2005-02-27 12:48 -------
I'm not sure I understand why it is thought that the C standard forbids the
conversion I'm talking about here. In fact, the final committee draft of the ISO
C standard that I have appears to be silent about the issue of multi-level
pointer conversions entirely. As noted by F. Hueffner, conversion rules are made
quite explicit in the C++ standard:

In ISO/IEC 14882 4.4.4, multi-level pointer conversions are explicitly
constrained by restricting automatic qualifier promotion to only those levels
for which _all_ preceding levels are const. The example that follows the
paragraph furthers the point by noting: "if a program could assign a pointer of
type T** to a pointer of type const T**...a program could inadvertently modify a
const object."

Absolutely. But that's not what I'm talking about. GCC issues an unsuppressible
warning when a conversion is made between:

char *const *object  -->  const char *const *object

or the equivalently innocuous

char **object --> const char *const *object

Nothing I can find in the FCD of the C standard forbids _any_ multi-level
conversion---safe or unsafe. GCC, however, warns about every such conversion
(even though it actually performs them). If it's going to complain, it really
should only complain about unsafe conversions as per the C++ standard---despite
the fact that all conversions appear to be legal in C.

Am I wrong? Where does it state in the C standard that you cannot perform a
multi-level qualifier promotion?

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20230

Reply via email to