Re: A: a new bug to old plain C

Александр Поваляев via Gcc-h elp <[email protected]>
Newsgroups gmane.comp.gcc.help
Message-ID <CAGT+J5z_i+PBK=z2UOFQU8-nBXZTCMbQP+4A+D=Oour8mGNCEQ@mail.gmail.com>
Hi there!

"False sense of security". Const is a hint to any C compiler to make code
more error-prone. So, it is always better to use as much "const" as
possible.
My point is that "if const might be used, it SHOULD be used". That is the
cornerstone.
I want to use it, so GCC compiler + SDK should make it possible. It is my
code and my design decisions being undertaken.

All discussions if it is possible to overcome or not "Const" restriction is
irrelivant here.

Respectfully,
Aleksandr G Povaliaev.

пн, 24 нояб. 2025 г. в 13:46, Henrik Holst <[email protected]>:

> The things is that this is unsafe and invalid due to it creating a false
> sense of security. Aka your "const Foo *" can change under your feet by
> _other_ code leading to your const here giving you a false sense of
> security. Yes it prevents you from modifying it locally but not some other
> code or thread from modifying your const pointer to now point to something
> else, hence the compiler issues an error here since you do not get what you
> think you are getting.
>
> /HH
>
> Den mån 24 nov. 2025 kl 11:10 skrev Александр Поваляев via Gcc-help <
> [email protected]>:
>
>> Hi there!
>>
>> The code is not invalid and neither of the links posted saying that "const
>> Foo * const * const" is invalid construction for C.
>> The links posted just are discussing that it might be UNSAFE to cast "Foo
>> **" -> "const Foo **" and recommending usage of "Foo **" -> "const Foo *
>> const *" instead.
>> It's OK. If you feel that it is unsafe, please don't use it. It is your
>> own
>> decision.
>>
>> But the syntax itself "const Foo * const * const" is correct and the
>> use-case I mentioned is quite simple and evident.
>> And so I need this code snipped to be compiled transparently over all the
>> GCC (and platform SDKs) available versions.
>>
>> Respectfully,
>> Aleksandr G Povaliaev.
>>
>>
>> пн, 24 нояб. 2025 г. в 01:48, David Brown <[email protected]>:
>>
>> > On 23/11/2025 21:45, Александр Поваляев via Gcc-help wrote:
>> > > Hi there!
>> > >
>> >
>> > This is getting /extremely/ frustrating.  /Please/ find some way to
>> > learn the C programming language - courses, books, good online
>> resources.
>> >
>> > And /please/ believe me when I say that people who have worked with C
>> > and C++ for decades, studied the standards, who serve on the standards
>> > committee, know better about these things than you do.  (I'm talking
>> > about Jonathan here, not myself - he really is a world-class expert
>> here.)
>> >
>> > > Either the links you've provided or the links you provided earlier
>> > > (yesterday) are irrelevant, cause they are just discussing if it is
>> safer
>> > > to convert "Foo_Type **" to "const Foo_Type **" or not.
>> > >
>> >
>> > The links are highly relevant.  They explain why you cannot convert from
>> > "char **" to "const char **".  That also explains why you cannot convert
>> > from "char **" to "const char * const * const".  Adding even more
>> > "const" qualifiers to the invalid conversion does not somehow magically
>> > make it work.
>> >
>> > > Once again, we are not converting "char** to const char**", we're
>> > > converting char** to const char * const * const".
>> > > And we're not discussing if it is safer or not, we are discussing GCC
>> > > compiler error.
>> > >
>> >
>> > The compiler is generating an error message because you wrote invalid
>> > code.  The error - or bug, if you like - is in /your/ code.  Not the
>> > compiler.  GCC is doing its job correctly here.
>> >
>> > >
>> > > Respectfully,
>> > > Aleksandr G Povaliaev.
>> > >
>> >
>> > I'm sorry, but signing the post with "respectfully" does not make it
>> > respectful.  You started the thread disrespectfully - insisting that
>> > there is a bug in GCC when you simply do not understand the relevant
>> > aspects of the C programming language.  And you have gone downhill since
>> > then, ignoring and rejecting the help and advice you have been given.
>> > Getting things wrong once is entirely understandable - this is a subtle
>> > point of the C language, and you are posting to a "help" list.  Doubling
>> > down on your ignorance when you have received the help and information
>> > you need, is a different matter entirely.
>> >
>> > Your code is flawed.  You need to fix it.  Mindlessly repeating your
>> > misunderstandings about how you think C works will not do anything but
>> > annoy people.
>> >
>> > David
>> >
>> >
>>
>
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.