C++ Issue with const char * on strchr
Andrew Haley
aph at redhat.com
Tue Mar 10 20:46:20 UTC 2009
Jochen Schmitt wrote:
> Conrad Meyer schrieb:
>> const char *str1, str2; str2 = strchr(str1, 'a');
>
>> But str2 must be a const char *.
>
>> Maybe I am wrong, I am not very familiar with C++.
>
>> Regards, My understanding is you can do something like this:
>
> I am doing something like this
>
> char *str2;
> const char *str1;
>
> str2 = strchr(str1, 'a'); // This fails on gcc-4.4
>
> When I write
>
> char *str2;
> const char *str1;
> char *temp = const_cast<char *>(str1);
>
> str2 = strchr(temp,'a') // This works
>
> Because this issue occurs only on gcc-4.4, I want to ask: is this
> a bug or a feature?
It's a feature.
Andrew.
More information about the fedora-devel-list
mailing list