Re: Cast "const char *" pointers to "char *" to avoid compiler warnings.

Corinna Vinschen <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
On Oct 10 16:37, Christophe Lyon wrote:
> On Wed, 10 Oct 2018 at 11:22, Corinna Vinschen <[email protected]> wrote:
> >
> > On Oct  2 11:10, Christophe Lyon wrote:
> > > On Tue, 2 Oct 2018 at 00:50, Craig Howland <[email protected]> wrote:
> > > >
> > > > On 10/01/2018 05:33 PM, Christophe Lyon wrote:
> > > > > Hi,
> > > > >
> > > > > GCC complains that some assignments loose the const-ness of several
> > > > > data. This small patch adds explicit (char *) casts, but I'm not
> > > > > familiar enough with what newlib does with these to be sure that they
> > > > > are not modified. Maybe the proper fix would be to declare the
> > > > > destinations as "const"?
> > > > >
> > > > > Christophe
> > > > If I understand what you're saying properly, it amounts to saying that you did
> > > > not verify whether the GCC warnings about discarding const are valid or not, yet
> > > > you are suppressing them.  Is this a proper understanding?  If so, it seems like
> > > > these proposed patches are a bad idea, as they might be hiding a real problem,
> > > > or changing the wrong thing.  (In a very quick look at locale.c, for example,
> > > > locale can definitely be written to--it is definitely not const. This implies
> > > > that the const on new_locale is what is wrong.)
> > >
> > > I did have this "very quick look at locale.c" before writing the
> > > patch, and not adding
> > > the cast at the assignment point means removing "const" from __loadlocale()
> > > prototype:
> > > char *__loadlocale (struct __locale_t *loc, int category, const char
> > > *new_locale)
> > > which in turn has a significant impact on the callers which I hope
> > > people familiar
> > > with this area can confirm, or not.
> >
> > The bug was, in fact, to define the third parameter as const, given it
> > gets potentially overwritten.  None of the incoming values is const
> > anyway.  I pushed a patch.
> >
> 
> Thanks.
> 
> However, when building for aarch64, I'm still seeing:
> newlib/libc/ctype/ctype_.c:179:16: warning: assignment discards
> ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
> 
> And I think my patch (or something similar) is still needed for jp2uc.c ?

I only had a look into the __loadlocal issue due to this discussion.
For everything else, please send a new patch.


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAlu+FGQACgkQ9TYGna5E
T6CP1w//YNzQhpFCWhHFMS40ofTK9c01Lolry/hLiWQAytTkQtkwNA5MeIDGz9X4
bspgVyB6o5VcIfR4MblrmVjSymRO3LFJqHkL5EFN+kPFkofLxq2qe7ARfNl16NFR
7eQzVAtb8ALVx6bok6DDXqYX/p6olfP0+qh0h5f8TnxYdLbUgKmm0QDAMT//z6AL
t+Na5lGCbIil+8ZFg8xQBbpXhguR+hedIykWBrlIMj6hNow/j/rUuNSlMg0K9So8
RnFcvfRpMHnWi/lNjgOnOCzKR/J5pc4GT5riJjSLdWniS8Bim7ksgzADIrAESsVH
IucrHVUxnswPLEYMx+HEfhIdy8PUiWi/2aHLbLgMgD5Q+2f6YMq3vakmALAX2EM+
3gcMTNpDytWsduudBH1fGVVyxGYDXU0h+GLdV97qJIFK10OjwKaPVibFaq8X7OUF
Gvlp9uTC9TLz3XM59LN9fFKAvJkGKCA/+riMxhG2QjUJ1pPG3aIQBIAcq/Drzcrf
lz6pCpScWb/19pXbLYfLlMaNv67in57B955prAUDYrJolgGVA5pDcxvG1YWwBbhD
AGDiE0+mtOuWWMkx7oES3cQ6HTxnw/ZVZFsjiMNKZaySXwxUCYfeCkPoDTxuh3kQ
15/FGXU8E56mAR+8dk8jHgtFihuqfo8k/W1vNfVrdJ9rDcNoEKM=
=64ev
-----END PGP SIGNATURE-----
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.