expected 'const uint8_t **' but argument is of type 'uint8_t **'
Hi all, we have several of such warnings. To my naive eyes to pass a pointer to a non-const area where it is expected a pointer to a const area should be perfectly safe, but the compiler (GCC) is not of the same opinion. Is that a compiler bug? Am I missing something? Regards. -- FFmpeg = Free Fancy Mystic Purposeless Ecumenical Game
Am Mittwoch, den 08.09.2010, 09:47 +0200 schrieb Stefano Sabatini:
we have several of such warnings. To my naive eyes to pass a pointer to a non-const area where it is expected a pointer to a const area should be perfectly safe, but the compiler (GCC) is not of the same opinion.
Is that a compiler bug? Am I missing something? It's not a bug, but a common C FAQ (I also made this mistake I first stumbled over this problem). See here: http://c-faq.com/ansi/constmismatch.html
Summary: passing uint8_t** to const uint8_t** is in fact unsafe, while passing uint8_t** to const uint8_t* const * would be safe, but C compilers are not required to be smart enough to know that, but C++ compilers are. Regards, Michael Karcher
Stefano Sabatini <stefano.sabatini-lala at poste.it> writes:
Hi all,
we have several of such warnings. To my naive eyes to pass a pointer to a non-const area where it is expected a pointer to a const area should be perfectly safe, but the compiler (GCC) is not of the same opinion.
Is that a compiler bug? Am I missing something?
It is a quirk of the C language. "const type *" and "type *" are considered different types. "type **" and "type *const *" would be compatible, only differing in the const. -- M?ns Rullg?rd mans at mansr.com
On Wed, Sep 08, 2010 at 09:24:23AM +0100, M?ns Rullg?rd wrote:
Stefano Sabatini <stefano.sabatini-lala at poste.it> writes:
Hi all,
we have several of such warnings. To my naive eyes to pass a pointer to a non-const area where it is expected a pointer to a const area should be perfectly safe, but the compiler (GCC) is not of the same opinion.
Is that a compiler bug? Am I missing something?
It is a quirk of the C language. "const type *" and "type *" are considered different types. "type **" and "type *const *" would be compatible, only differing in the const.
well explained what i would wish for is to be able to disable this pedantry in gcc while leaving all the other const checking in place. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Avoid a single point of failure, be that a person or equipment.
participants (4)
-
ffmpeg@mkarcher.dialup.fu-berlin.de -
mans@mansr.com -
michaelni@gmx.at -
stefano.sabatini-lala@poste.it