This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFA: Fix bootstrap/44637


On Sat, Jul 10, 2010 at 10:32 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Sat, Jul 10, 2010 at 10:19:49AM +0200, Richard Guenther wrote:
>> > --- config/rs6000/rs6000.c ? ? ?(revision 161213)
>> > +++ config/rs6000/rs6000.c ? ? ?(working copy)
>> > @@ -21252,12 +21252,13 @@ toc_hash_eq (const void *h1, const void
>> > ?const char *
>> > ?rs6000_xcoff_strip_dollar (const char *name)
>> > ?{
>> > + ?const char *cp;
>> > ? char *strip, *p;
>> > ? int len;
>> >
>> > - ?p = strchr (name, '$');
>> > + ?cp = strchr (name, '$');
>> >
>> > - ?if (p == 0 || p == name)
>> > + ?if (cp == 0 || cp == name)
>> > ? ? return name;
>> >
>> > ? len = strlen (name);
>>
>> Huh, I wonder why the same diagnostic is not issued for the code below which
>> reads
>>
>> ? strip = (char *) alloca (len + 1);
>> ? strcpy (strip, name);
>> ? p = strchr (strip, '$');
>> ? while (p)
>> ? ? {
>> ? ? ? *p = '_';
>> ? ? ? p = strchr (p + 1, '$');
>> ? ? }
>>
>
> Because strchr is char *strchr (const char *, int); for C
> and char *strchr (char *, int); const char *strchr (const char *, int); for C++?
> In the first snippet the argument is const char *, so the result is const
> char * too (for C++ only, otherwise char *), while in the second snippet
> the argument is char *, so the result is char * too.

Ah, that makes sense.  I didn't look closely enough.

>> why not use our "friendly" CONST_CAST macro here?
>
> Why?

Not necessary in that case then.

Richard.

> ? ? ? ?Jakub
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]