Re: A: a new bug to old plain C
Александр Поваляев via Gcc-h elp <[email protected]>
| Newsgroups | gmane.comp.gcc.help |
|---|---|
| Message-ID | <CAGT+J5y4Cf599zrZDKF6iTuWybAMNkhUNxSmya1kxLOGv7i3oQ@mail.gmail.com> |
Hi there!
It should be stated somewhere in C standard. You and your friends opinion
is very important, but it is only an opinion, not a standard :D
Respectfully,
Aleksandr G Povaliaev.
P.S. You example is wrong and irrelevant.You've missed at least one "const"
:D
void foo(int const *const p)
{
int *nonconst_p;
/*HERE!!!*/ *const* int *const *const pp = &nonconst_p;
*pp = p;
*nonconst_p = 42;
}
ср, 26 нояб. 2025 г. в 09:27, Simon Richter <[email protected]>:
> 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
>