Re: A: a new bug to old plain C

Matthias Pfaller <[email protected]>
Newsgroups gmane.comp.gcc.help
Organization marco Systemanalyse und Entwicklung GmbH
Message-ID <[email protected]>
On 2025-11-26 07:27, Simon Richter wrote:
> Hi,
>
> On 11/26/25 3:14 PM, Александр Поваляев via Gcc-help wrote:
>
>> Could somebody point out where in the C standard a conversion "Foo**" ->
>> "const Foo * const * const" is prohibited?
>
> It's disallowed because
>
>     void foo(int const *const p)
>     {
>         int *nonconst_p;
>         int *const *const pp = &nonconst_p;
>         *pp = p;
>         *nonconst_p = 42;
>     }
>
> would allow overwriting a variable passed in as pointer-to-const.
>
>    Simon

Sorry Simon,

*pp = p;

would not be possible because "*pp" is marked as const  in the declaration of pp. It 
really hurts that I have to pour additional fuel into the fire...

regards, Matthias
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.