Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connectionsPath: ...!weretis.net!feeder9.news.weretis.net!i2pn.org!i2pn2.org!.POSTED!not-for-mail
From: Richard Damon
Newsgroups: comp.lang.c
Subject: Re: No warning at implicit removal of const. Was: relearning C: why
does an in-place change to a char* segfault?
Date: Fri, 2 Aug 2024 15:11:20 -0400
Organization: i2pn2 (i2pn.org)
Message-ID:
References:
<20240801174026.00002cda@yahoo.com>
<87zfpvfdk4.fsf@nosuchdomain.example.com>
<87v80ig4vt.fsf@nosuchdomain.example.com>
<82cc9501de86336cdef9fe610bce8e75238fb679@i2pn2.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 2 Aug 2024 19:11:20 -0000 (UTC)
Injection-Info: i2pn2.org;
logging-data="1215790"; mail-complaints-to="usenet@i2pn2.org";
posting-account="diqKR1lalukngNWEqoq9/uFtbkm5U+w3w6FQ0yesrXg";
User-Agent: Mozilla Thunderbird
In-Reply-To:
X-Spam-Checker-Version: SpamAssassin 4.0.0
Content-Language: en-US
Bytes: 2702
Lines: 34
On 8/2/24 2:58 PM, James Kuyper wrote:
> On 8/2/24 14:42, Richard Damon wrote:
>> On 8/2/24 2:24 PM, Keith Thompson wrote:
>>> Richard Harnden writes:
>>> [...]
>>>> Is there any reason not to always write ...
>>>>
>>>> static const char *s = "hello, world";
>>>>
>>>> ... ?
> ...
>>> There's no good reason not to use "const". (If string literal objects
>>> were const, you'd have to use "const" here.)
> ...
>> The one good reason to not make it const is that if you are passing it
>> to functions that take (non-const) char* parameters that don't
>> actually change that parameters contents.
>
> Actually, that's not a good reason. If you can't modify the function's
> interface, you should use a (char*) cast, which will serve to remind
> future programmers that this is a dangerous function call. You shouldn't
> make the pointer's own type "char *".
>
>
Depends on the library and how many times it is used. It may be a
perfectly safe call, as the function is defined not to change its
parameter, but being external code the signature might not be fixable.
Adding the cast at each call, may cause a "crying wolf" response that
trains people to just add the cast where it seems to be needed (even if
not warrented). You likely DO want a note at the statement explaining
the situation.